File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Doubt in using getParameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Doubt in using getParameter" Watch "Doubt in using getParameter" New topic

Doubt in using getParameter

Karthik Vaidiswaran

Joined: Jan 11, 2005
Posts: 16
My doubt is about getParameter method of the HttpServletRequest object. I have a form that submits 3 values(HPUnix, Solaris, Linux). When I retrieve these values and display them I get the values in reverse-alphabetical order , i.e (Solaris, Linux, HPUnix). I think that parameter values from a form are submitted in the order in the which the corresponding elements appear in the form. I assume that the reverse alhabetical order is because of getParameter method. Please let me know whether I am correct.

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

They're being stored in a map, which means that you should not count on them coming out in any particular order. If you need them sorted, use getParameterNames, sort that and use the sorted list to retrieve them.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Karthik Vaidiswaran

Joined: Jan 11, 2005
Posts: 16
Hello Ben,

Thanks a lot for the reply.

I agree. Here's the link:
subject: Doubt in using getParameter
It's not a secret anymore!