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.

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.
Then, declare a hidden element and set its value to the number of elements
you use, like

<input type="hidden" name="number-of-elements" value="2" />

Then, in your code, do something like this.

int numberOfElements =
Integer.parseInt(request.getParameter("number-of-elements"));
for (int i = 0; i < numberOfElements; i++) {
        String value = request.getParameter("element" + Integer.toString(i));
        // do something
}

You might be able to do it without the hidden element with the following
code,
I'm not sure.

int i = 0;
String value;
while ((value = request.getParameter("element" + Integer.toString(i))) !=
null) {
        // do something with value
        i++;
}


[ Matthias Carlsson ]
[ Programmer (Java, XML/XSL, CGI/Perl, HTML/JS) ] [ Web Designer ]
[ E-Mail : [EMAIL PROTECTED] ] [ ICQ: 1430647 ]

> -----Ursprungligt meddelande-----
> Fran: A mailing list for discussion about Sun Microsystem's Java Servlet
> API Technology. [mailto:[EMAIL PROTECTED]]For Krzysztof
> Zielinski
> Skickat: den 12 mars 2001 09:52
> Till: [EMAIL PROTECTED]
> Amne: How to get request prameters in right order.
>
>
> Hello.
>
> I am stuck in the following problem:
>
> 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.
>
>
> Now I'm doing it with request.getParameterNames() but parameter
> names are not in the right order.
> ....
> Enumeration enum = request.getParameterNames();
> ...
>
> --
> 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

___________________________________________________________________________
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

Reply via email to