tags:

views:

50

answers:

3

Possible Duplicate:
Ordering of values in HttpServletRequest.getParameterValues()

We have J2EE based web application. On server side, we want to get parameters in exactly same order in which sent by client browser. We tried request.getParameterMap() and request.getParameterNames() but these methods does not returns parameters in same sequence as send by client browser.

How can we get parameters in exactly same order in which sent by client browser?

+1  A: 

Request parameters are stored internally in a map so you should make no assumptions about their order.

But why don't you just read them as they are and then sort them?

mgamer
A: 

This is not even Java related. You can't even rely on the browser to send the request params in a specific order. Besides that as @mgamer noted, you can't make assumptions about the parameters order.

What you can do if you need to read the params in some predefined order, is to create some scheme in which you can do that easily. For example send a JSON object or use some simple format like param1=val&param2=another-val etc.

Eran Harel
it is mgamer's answer, I just edited a typo.
Bozho
oops, sorry @bozho
Eran Harel
A: 

I am not sure why do we need to rely upon order of the parameters sent. Can you let know why thats required, may be you can solve the problem by alternative methods.