• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request Attributes and Request Parameters

 
Kanika Sud
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 83
MySQL Database Netbeans IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 83
MySQL Database Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 136
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic