You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Martin van Dijken <mv...@madocke.nl> on 2003/10/08 11:46:06 UTC

Order of parameters

I've been trying to create an automated form handler. This form handler could be a lot more effective if the request parameters were in the order they were put on the form. Now most browsers send this information over HTTP in the order they were found in the form. However, because the parameters are in Tomcat put into a Hashtable, the order is lost and can never be rebuilt.

First of all, does anybody have a problem with a little code to keep the parameters in order?

Second, please comment my proposed solution: 

The best way I can think of to change this involves creating an extension of Hashtable. At the moment a parameter is put into the Hashtable, the key is put into an Arraylist. When request.getParameterNames() is called, the parameters are returned in the order they are found in the ArrayList. This would keep the speed of accessing request.getParameter() fast and put a little overhead at request creation and getParameterNames.


Martin van Dijken

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Order of parameters

Posted by Dirk-Willem van Gulik <di...@webweaving.org>.

On Wed, 8 Oct 2003, Martin van Dijken wrote:

> I've been trying to create an automated form handler. This form handler
> could be a lot more effective if the request parameters were in the
> order they were put on the form. Now most browsers send this information

MOST browsers; certainly not all.

> over HTTP in the order they were found in the form. However, because the
> parameters are in Tomcat put into a Hashtable, the order is lost and can
> never be rebuilt.

Unfortunately it is not uncommon for anti-virus/filtering proxies to mess
with the order as well.

If you are requiring order it may makes the most sense to NOT trust the
wire - but do the ordering yourself on entry as described.

But bear in mind that it is generally much much safer to check for a
explicit field name in the Hash table than to rely even on the ordering; a
broken proxy (common) or some malicious person (less common) may have
removed or added fields.

So this idea may not be one which leads to safe habits.

DW

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org