File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Request Attributes and Request Parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Request Attributes and Request Parameters" Watch "Request Attributes and Request Parameters" New topic
Author

Request Attributes and Request Parameters

Kanika Sud
Greenhorn

Joined: May 09, 2011
Posts: 21
Hi.

I have a list box which allows multiple select. The results allow for pagination. When I move to the next page, the multiple selection does not hold. Only the first selection from the list box comes up in the request parameters. I want the selection(s) to hold through all the pages.
Also if I refresh the page, the list box does not hold the selection(s) at all... can this be changed.

Since this is related to request parameters,
I would want to know is can we add multiple request parameters by the same name?
As in How do I accomplish: ?devicePlatform=iPhone&devicePlatform=iPad&curPage=2

And if someone could make the difference betwen request parameters and attributes clear, it would be helpful.

Thanks,
Kanika.


vinayak jog
Ranch Hand

Joined: Apr 01, 2011
Posts: 81

Why don't you try to store the selected object list in the session object so that it is accessible throughout the session
Kanika Sud
Greenhorn

Joined: May 09, 2011
Posts: 21
Thanks for the prompt reply.
vinayak jog wrote:Why don't you try to store the selected object list in the session object so that it is accessible throughout the session


That could be a solution. But I wanted to use request parameters/attributes along with a clear picture of these two.

Also, my question still stands: can we accomplish example.com/abc?p=1&p=2&p=3 If so, how?

In other words, if I want to pass an array as the request parameters/attributes, how do I do it... and in this case how il it appear in the query string?
Thanks,
Kanika
vinayak jog
Ranch Hand

Joined: Apr 01, 2011
Posts: 81

Ya you can do it by storing your selected objects in a string and in each JSP you need to access that string and append newly added object to the string but this has a limitation you cannot exceed some number i.e., url cannot be infinitely big, so better you use session object which sufficiently big to hold your data and accessible throughout the session. And passing parameters using url is not good practice
Sabarish Venkat
Ranch Hand

Joined: Jan 18, 2012
Posts: 136

To use the array of values in request parameters use getParameterValues() for example like this ,
Once you store the parameter values retrieve it in next page using loop iterator
Kanika Sud
Greenhorn

Joined: May 09, 2011
Posts: 21
Sabarish Venkat wrote:To use the array of values in request parameters use getParameterValues() for example like this ,
Once you store the parameter values retrieve it in next page using loop iterator


Let me explain the whole situation because none of these is an exact solution. My fault, really.

The struts tag I'm using looks something like:



Now if I try to paginate between results the following happen:
A single selection holds.
A multiple selection does not.

I suspect it happens because the setter is a String and not an array. I can't change this to an array now because it will lead to a lot of change in existing code.


Thanks,
Kanika.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Request Attributes and Request Parameters