This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting back param values in the correct order

 
Nicholas Giaimo
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

After doing some searching on here and on Google I have not been able to find a definitive answer the the following question.

I am currently trying to get a list of all the values from this small form



via the following code in results.jsp



Now, this works, but the issue is that they are not in the same order as they were in the form. I would normally just call ${param.(nameofparameter)} but I will not know which form is being sent to results.jsp.

Basically, I need to get all of the param values from any possible form without knowing the name of the parameters, IN ORDER. Is that possible?

Thanks.
 
Paul Clapham
Sheriff
Pie
Posts: 20945
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nicholas, welcome to the Ranch!

Short answer: No, that isn't possible.

Longer answer: I've never heard of anybody requiring an order for the parameters. Why do you need one? What problem is that solving? (There might be a way of putting the parameters in order, but it would be up to you to implement that.)
 
Nicholas Giaimo
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the welcome!

What I was planning on doing was to was have them added to a List of Strings and then sent as a parameter in a method to generate an output. The method would know for each form which parameter would be where in the List.

Now that I am thinking about it without that plan since it would not work, I could probably just use a Map, correct? I have never used Maps before so I will have to look that up.

Anyway thank you for the answer!
 
Paul Clapham
Sheriff
Pie
Posts: 20945
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, a Map would be ideal because that's in fact how the parameters are stored in the request. And you'll find that HttpServletRequest has a getParameterMap method which gives you that Map. So yes, check out Map. Here's a link to the Java Collections Tutorial which tells you almost everything you would ever want to know about collections -- including maps.

(And after you reach a certain point in that tutorial, you'll see why you aren't getting the parameters in the order they appeared in your form.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic