tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Trasuk" <>
Subject RE: Ordering of parameters in HTTPRequest Object
Date Mon, 16 Jul 2001 16:37:16 GMT
	I agree with Michael, it's not a great idea to depend on the order of the
request parameters.  It makes the code more fragile and less resilient to
maintenance.  For example, you might want to change the layout of the form
to improve usability or change the aesthetics, which would change the order
in which the controls appear, and hence the order in which the fields are
submitted, which breaks your servlet.

	Far better to name the parameters.  If naming is not possible, you might
want to look into reading the request body directly using the
ServletRequest.getReader() or ServletRequest.getInputStream() methods.  You
would then need to parse the data to extract the parameters.  I would
imagine that you could find similar code in the Tomcat sources, but it's
still going to be some work.

Greg Trasuk, President
StratusCom Manufacturing Systems Inc. - We use information technology to
solve business problems on your plant floor.

-----Original Message-----
From: Michael Wentzel []
Sent: Monday, July 16, 2001 8:39 AM
To: ''
Subject: RE: Ordering of parameters in HTTPRequest Object

> Hello all, I am new to this mailing list, and Tomcat, so please pe
> patient...
> I am using Servlets to recieve html form submissions.
> 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...
> The post data comes in in the proper order, but I can not recover the
> ordering.  If it was only 1 form I was dealing with, I could
> write code to
> format a response, but the app is very generalized, and it is
> designed to
> handle many different forms.
> So the question.   Is there no way in tomcat to preserve the
> ordering of
> parameters from a form submission?

No.  This is servlet API thing, not a tomcat thing.  I think it's a bad
idea to develop servlet to depend on the order in which a request object
is formed because you never know for sure that an ordering is going to
be fixed.  For example, say a hashing algorithm is used for speed up
access.  How do you order the elements of a hash table?  The only thing
I could suggest is preface every form element with its' order, 1st element
would be 0_elementname and 9th element would be 8_elementname, then order
the elements yourself, but I think this is kind of sloppy.

Michael Wentzel
Software Developer
Software As We Think -

View raw message