You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Peter Choe <ch...@mindspring.com> on 2003/01/09 17:40:19 UTC

reading forms

is there a way to specify the order of the parameters are read from a form 
in a servlet?

it seems that if i do request.getParameterNames() there is no logic to 
which parameters are read first.

Peter Choe



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: reading forms

Posted by Peter Choe <ch...@mindspring.com>.
thanks for the information.

i was just trying to write a generic servlet to read in any forms and email 
or print the results to the users.

Peter Choe

At 11:54 AM 1/9/2003, Jason Pyeron wrote:

>for lack of a better description the names are radmonized. This is because
>they are in a hash.
>
>if you need them in a given order, you may want to "number" them.
>
>
>ex:
>
>  <form>
>   <input name="field_00_id"/>
>   <input name="field_01_fname"/>
>   <input name="field_99_memo"/>
>   <input name="field_50_authnum"/>
>  </form>
>
>  then you can take request.getParameterNames() and sort it. if you still
>have trouble using it, then you can make a translation hash
>
>for all in (request.getParameterNames())
>  xlatehash.put(val.substring(10),val);
>
>now you can access them in order or by unprefixed name.
>
>does this help?
>
>IMHO: if you need the names in order there is a problem with you logic,
>cause there is no gaurentee that the browser will send them in any give 
>fasion.
>
>-jason pyeron
>
>--
>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>-                                                               -
>- Jason Pyeron                   http://www.pyerotechnics.com   -
>- Owner & Lead                  Pyerotechnics Development, Inc. -
>- +1 410 808 6646 (c)           500 West University Parkway #1S -
>- +1 410 467 2266 (f)           Baltimore, Maryland  21210-3253 -
>-                                                               -
>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
>This message is for the designated recipient only and may contain
>privileged, proprietary, or otherwise private information. If you
>have received it in error, purge the message from your system and
>notify the sender immediately.  Any other use of the email by you
>is prohibited.
>
>
>
>
>On Thu, 9 Jan 2003, Peter Choe wrote:
>
>is there a way to specify the order of the parameters are read from a form
>in a servlet?
>
>it seems that if i do request.getParameterNames() there is no logic to
>which parameters are read first.
>
>Peter Choe
>
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: reading forms

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 9 Jan 2003, Peter Choe wrote:

> Date: Thu, 09 Jan 2003 11:40:19 -0500
> From: Peter Choe <ch...@mindspring.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: tomcat-user@jakarta.apache.org
> Subject: reading forms
>
> is there a way to specify the order of the parameters are read from a form
> in a servlet?
>
> it seems that if i do request.getParameterNames() there is no logic to
> which parameters are read first.
>

There is no guaranteed order.  In fact, there's no guaranteed order for
the client to send request parameters to the server either.

> Peter Choe
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: reading forms

Posted by Dan Lipofsky <da...@nuserve.com>.
> for lack of a better description the names are radmonized. This is because
> they are in a hash.
>
> if you need them in a given order, you may want to "number" them.

If it is a GET request you can do request.getQueryString()
and parse the query string by hand.  A bit painful and it
doesn't work for POST requests.

> IMHO: if you need the names in order there is a problem with you logic,
> cause there is no gaurentee that the browser will send them in any give
fasion.

unless it is a GET request and the URL is static or constructed
by javascript with the parameters in the URL.  Then you have a
gaurenteed order.
- Dan

> On Thu, 9 Jan 2003, Peter Choe wrote:
>
> is there a way to specify the order of the parameters are read from a form
> in a servlet?
>
> it seems that if i do request.getParameterNames() there is no logic to
> which parameters are read first.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: reading forms

Posted by Jason Pyeron <ja...@pyeron.com>.
for lack of a better description the names are radmonized. This is because 
they are in a hash.

if you need them in a given order, you may want to "number" them.


ex:

 <form>
  <input name="field_00_id"/>
  <input name="field_01_fname"/>
  <input name="field_99_memo"/>
  <input name="field_50_authnum"/>
 </form>

 then you can take request.getParameterNames() and sort it. if you still 
have trouble using it, then you can make a translation hash

for all in (request.getParameterNames())
 xlatehash.put(val.substring(10),val);

now you can access them in order or by unprefixed name.

does this help?

IMHO: if you need the names in order there is a problem with you logic, 
cause there is no gaurentee that the browser will send them in any give fasion.

-jason pyeron

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-                                                               -
- Jason Pyeron                   http://www.pyerotechnics.com   -
- Owner & Lead                  Pyerotechnics Development, Inc. -
- +1 410 808 6646 (c)           500 West University Parkway #1S -
- +1 410 467 2266 (f)           Baltimore, Maryland  21210-3253 -
-                                                               -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

This message is for the designated recipient only and may contain 
privileged, proprietary, or otherwise private information. If you
have received it in error, purge the message from your system and 
notify the sender immediately.  Any other use of the email by you 
is prohibited.




On Thu, 9 Jan 2003, Peter Choe wrote:

is there a way to specify the order of the parameters are read from a form 
in a servlet?

it seems that if i do request.getParameterNames() there is no logic to 
which parameters are read first.

Peter Choe



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>