Hello Kevin,
Thanks for a replay.
>> 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.
I have to write a Java class similar to perl CGI::XMLForm - Extension of CGI.pm which
reads/generates formated XML.
KM> The problem is that the servlet container takes the request parameters
KM> from the input stream and stores them in a Collection (probably a
KM> HashMap or Hashtable for easy retrieval with
KM> getParameterValues(String)). Because of the way keys are stored in the
KM> Collection, the set of keys is not necessarily returned in the same
KM> order as they were sent.
This is a problem. Original SUN JSDK have a "bug".
>> 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.
KM> But if you can do this, then you know the order already. The original
KM> question implies that the order is not known, but that the servlet needs
KM> to get the parameters in the same order as they appear in the form.
KM> If the form structure is unknown by the servlet developer, then the only
KM> way to get the parameters in the same order in which they are sent is to
KM> read the InputStream directly. That is, at the beginning of the doPost
KM> method, do the following:
KM> InputStream in = request.getInputStream();
KM> And then use input stream methods to parse the posted data. Note, that
KM> if you do this, you will probably not be able to use any of the
KM> getParameter(), getParameterValues(), or getParameterNames() methods.
I have first asked on SERVLET-INTEREST mailing list.
I hope that someone solved this problem, and wrote a fuction returnig a
parameters with a correct order.
--
Best regards,
Krzysztof mailto:[EMAIL PROTECTED]
___________________________________________________________________________
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