Aaah... now your problem makes more sense. I assumed that you would know
ahead of time what the form looked like. James Wilson assumed you have
control over the form.

But in the case where you have no control over the form AND you cannot
know ahead of time what the form looks like, then you are stuck. The
only way to know how the parameters were sent by the browser is to
directly read the input stream. (And that assumes the parameters are
sent in the same order as they appear on the page. Usually a reasonable
assumption, but you never know which browser is going to do something
different.)

I'm curious, though, if you don't know what the parameters are ahead of
time, how can you possibly create an application that is able to do
anything that is functional? Doesn't some object somewhere in the
application know what parameters to expect? I don't see how one can
create a useful web app when the form can have arbitrary parameter names
and parameters.

Generally, I am of the opinion that the servlet should not have any
business logic in it. For one web app I worked on, I put the business
logic in a regular Java object (as opposed to the servlet). Thus the
servlet wasn't tied in any way to the html form. I could change the form
any way I wanted, and it didn't affect the servlet. The servlet simply
got all the parameters from the request, stuffed them into another
hashtable, and passed the hashtable to the business object. Now, the
business object WAS tied very closely to the form. The business object
had to know exactly what were the parameter names in the form. The form
had to use the exact names expected by the object.

K Mukhar

Tiago Antão wrote:
>
> Hi!
>
> On Tue, 17 Oct 2000, James Wilson wrote:
>
> > The way I fixed the problem was to use getParameterNames and to make
> > each name Comparable in the order I needed.
> >
> > <input name="1_Name" . . .>
> > <input name="2_Address" . . .>
> >
>
>   First of all, I'd like to thank for all the answers.
>
>   The problem is that the servlet is a general purpose one, which, does
> not control the html form. So I can't use parameters whose name is
> ordered. I can't also use javascript because I don't generate the form. I
> can't also get the paramaters by name because I don't know in advance that
> name (I currently check the Enumeration getParameterNames, which is
> returned unordered. I've looked at tomcat implementation and it's based on
> an HashTable, so it's not easy to tweak the implementation :-) ).

___________________________________________________________________________
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