• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 279
  • Last Modified:

Pass query string parameters dynamically from action class

Hi folks,
I am having a simple problem which I am frankly unable to solve. I want to pass query string parameters from the action class. I want to append it with the action mapping and send it with the request. I want to know how to achieve this solution?

Simple example code will do good for me....because I am in need of it.

Regards
0
pampa34
Asked:
pampa34
1 Solution
 
bloodredsunCommented:
I assume that you're using Struts here as you haven't said.

The query string is available to the view layer (your jsp) so you don't need to pass them explicitly. If you are talking about passing parameters created in the action to the view layer, that's a bit of an odd thing to do as that is what your actionForm is for.

An alternative approach would be to use an extra javabean that you can stick in the request in the action and then access it in the jsp using jstl.

e.g.

action
------------
ParamBean pb = new ParamBean() ; //map-backed bean
pb.addParam("param1" , "Hello there") ; //enter into bean hashmap
pb.addParam("param2" , "Hello back") ; //enter into bean hashmap
request.setAttibute("paramBean" , pb ) ; //save into the request

jsp
------------
<c:out value='${requestScope.paramBean.param[0]}'/>
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now