You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Bob Byron <bb...@radit.com> on 2001/12/17 15:51:24 UTC

Re: Ordering of parameters in HTTPRequest Object

Sean,

Did you find a solution to the parameter ordering issue of a form?  I 
am interested in receiving the parameters in order.  I want to make 
a generic servlet that emails forms to me and maintains the order 
of the fields on the form.  Nothing is "dependent", but aesthetically 
it works out better if I just use the order from the form.  It seems 
a shame that the servlet API discards the data.  (At least that is 
what I gathered from the previous thread.)

Thank You,
Bob Byron

----- Original Message ----- 
From: "Sean Tiley" <se...@hotmail.com>
> Problem is that the form fields are in a particular order on the form, but 
> when I get the Parameters from the request object this field order is 
> gone...
 
----- Follow-up Message ----- 
From: "Sean Tiley" <se...@hotmail.com>
> I will look into the getInputStream().  It seems reasonable, but then 
> wont I have to pass this around with the request object?



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Ordering of parameters in HTTPRequest Object

Posted by "Christopher K. St. John" <ck...@distributopia.com>.
Tom Drake wrote:
> 
> It seems to me that making your servlet / jsp dependant on the
> order of the parameters is a huge mistake, even if this order
> is guaranteed by all browsers and by Tomcat and all other
> servlet containers.
> 

 Mechanism not policy.

 If you thing maintaining the order of form parameters
is of questionable utility, just take a look at the
requirements for ServletRequest.getLocales() (hint:
the "q" parameter is a real hoot.)

 But it's in the spec, so somebody, somewhere has
probably come up with a use for it.

 The servlet spec inherits Accept-Language semantics
from the HTTP spec, just like it arguably ought to
inherit form-ordering semantics from the HTML spec.
(That is, assuming I'm interpreting the HTML spec
correctly)

 I don't really have a great deal of emotion tied up
in the issue, it's more of a specification nit. But
on such nits is interoperability built :-)


-- 
Christopher St. John cks@distributopia.com
DistribuTopia http://www.distributopia.com

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Ordering of parameters in HTTPRequest Object

Posted by Tom Drake <rt...@pobox.com>.
This may be a dumb question, but do you really care about the
order of the form parameters?

It seems to me that making your servlet / jsp dependant on the
order of the parameters is a huge mistake, even if this order
is guaranteed by all browsers and by Tomcat and all other
servlet containers.

The problem is that your servlet that processes the request will
be tied to the gui layout of the form. If the gui designer decides
to lay the form out in a different way next week, your code
will break.

IMHO, your solution would be far more robust if it relied on the
names of the parameters, and not the order in which they're
received.

Tom Drake


----- Original Message ----- 
From: "Christopher K. St. John" <ck...@distributopia.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Monday, December 17, 2001 4:33 PM
Subject: Re: Ordering of parameters in HTTPRequest Object


| "Craig R. McClanahan" wrote:
| > 
| > There are no guarantees that a browser will send the
| > request parameters in the order they appear on the form
| >
| 
|  http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1
| 
|  application/x-www-form-urlencoded  
| 
|    This is the default content type. Forms submitted with
|    this content type must be encoded as follows:
| 
|    1. Control names and values are escaped ...
| 
|    2. The control names/values are listed in the order they
|       appear in the document. ...
| 
|  That's just for urlencoded forms, but then again that's
| the only content-type the servlet spec makes any
| promises about.
| 
|  It seems reasonable that a servlet container should
| return the params in order for content-types where 
| the ordering is guaranteed. 
| 
| -- 
| Christopher St. John cks@distributopia.com
| DistribuTopia http://www.distributopia.com
| 
| --
| To unsubscribe:   <ma...@jakarta.apache.org>
| For additional commands: <ma...@jakarta.apache.org>
| Troubles with the list: <ma...@jakarta.apache.org>
| 
| 
| 


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Ordering of parameters in HTTPRequest Object

Posted by "Christopher K. St. John" <ck...@distributopia.com>.
"Craig R. McClanahan" wrote:
> 
> There are no guarantees that a browser will send the
> request parameters in the order they appear on the form
>

 http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1

 application/x-www-form-urlencoded  

   This is the default content type. Forms submitted with
   this content type must be encoded as follows:

   1. Control names and values are escaped ...

   2. The control names/values are listed in the order they
      appear in the document. ...

 That's just for urlencoded forms, but then again that's
the only content-type the servlet spec makes any
promises about.

 It seems reasonable that a servlet container should
return the params in order for content-types where 
the ordering is guaranteed. 

-- 
Christopher St. John cks@distributopia.com
DistribuTopia http://www.distributopia.com

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Ordering of parameters in HTTPRequest Object

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

On Mon, 17 Dec 2001, Bob Byron wrote:

> Date: Mon, 17 Dec 2001 08:51:24 -0600
> From: Bob Byron <bb...@radit.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: tomcat-user@jakarta.apache.org, seantiley@hotmail.com
> Subject: Re: Ordering of parameters in HTTPRequest Object
>
> Sean,
>
> Did you find a solution to the parameter ordering issue of a form?  I
> am interested in receiving the parameters in order.  I want to make
> a generic servlet that emails forms to me and maintains the order
> of the fields on the form.  Nothing is "dependent", but aesthetically
> it works out better if I just use the order from the form.  It seems
> a shame that the servlet API discards the data.  (At least that is
> what I gathered from the previous thread.)
>

There are no guarantees that a browser will send the request parameters in
the order they appear on the form, so there was nothing for the servlet
API to "discard" in this respect.

If you really want to process the parameters in the order the browser sent
them (on the assumption that this matches the form order), you can read
the query string (on a GET) or input stream (on a POST) and parse it
yourself, instead of calling request.getParameter().

> Thank You,
> Bob Byron
>

Craig McClanahan


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>