Posted on 2004-08-06
I am submitting a form to a servlet using method POST. My form has many parameters (hidden and visible). When I use request.getParameterMap() in the doPost() method in the servlet (assuming that request is an instance of HttpServletRequest), I get a java.util.Map of parameter names and values. Using a java.util.Iterator in the java.util.Set for the keySet in the Map, I can obtain the names of all the parameters passed by the form. Funny enough: they are not in the order they exist in the form. The same thing happens on doGet if I pass the parameters on the URL while calling the servlet. Therefore, if the call to the servlet is like ServletName?param1=value1¶m2=value2¶m3=value3..., the iteration through the keySet does not result param1, param2, param3,... in order but in a completely unpredictable order. Any idea how to fix this? Thanks a lot in advance.