> Krzysztof Zielinski wrote:
> >
> > I'm trying to get all parameters from request in right order.
> > Right order means that I need parameters in order as they were in
> > HTML Form.
Matthias Carlsson wrote:
>
> I don't know how browsers are supposed to send parameters, if they
> are required to send them as they appear in the HTML code etc. but perhaps
> the following will work for you.
Browsers are required to submit the form data in the same order it
appears in the form. From the archives (search for "order of post
data"):
"Christopher K. St. John" wrote:
>>
>> HTML 4.01 Specificationm, 17.13.4 Form content types:
>>
>> 2. The control names/values are listed in the order they
>> appear in the document. The name is separated from the
>> value by `=' and name/value pairs are separated from
>> each other by `&'
The current spec is at http://www.w3.org/TR/html4/
The problem is that the servlet container takes the request parameters
from the input stream and stores them in a Collection (probably a
HashMap or Hashtable for easy retrieval with
getParameterValues(String)). Because of the way keys are stored in the
Collection, the set of keys is not necessarily returned in the same
order as they were sent.
> Name all you form elements with something like "element0" for the first one,
> "element1" for the second one and so on as they appear in your code.
But if you can do this, then you know the order already. The original
question implies that the order is not known, but that the servlet needs
to get the parameters in the same order as they appear in the form.
If the form structure is unknown by the servlet developer, then the only
way to get the parameters in the same order in which they are sent is to
read the InputStream directly. That is, at the beginning of the doPost
method, do the following:
InputStream in = request.getInputStream();
And then use input stream methods to parse the posted data. Note, that
if you do this, you will probably not be able to use any of the
getParameter(), getParameterValues(), or getParameterNames() methods.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html