File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes post parameter in sort of input ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "post parameter in sort of input ?" Watch "post parameter in sort of input ?" New topic

post parameter in sort of input ?

heiner weilandt
Ranch Hand

Joined: Sep 10, 2002
Posts: 46
i want to develop an servlet that takes unknown post-parameters one by one and take it to a mail. i have the problem that the right sort of these fields in the html-file are changes. i don't know the names of the parameters and i don't know how many parameters they are.
- do you habe any idea, how i can get the orignial-sort from the html-file ?
- can i get the original content-parameter-string and do it one by one on my own ?
please help.
Dominic Paquette
Ranch Hand

Joined: Dec 13, 2002
Posts: 64
to get your parameters names you can use
HttpServletRequest.getParameterNames() or getParameterMap(), but you won't get them in the same order as the <input> feilds in you html form so I guess it's no use to you.
to get the query string try HttpServletRequest.getQueryString()
If the order of the parameters are important for you, maybee you can name you parameters with a counter or somethig like
<input type="text" name="param1"/>
<input type="text" name="param2"/>
<input type="text" name="param3"/>
Hope this helps
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
I think getQueryString only gets the query part of the URL so it would only work with a GET. You could just get POSTed data as a stream using getInputStream, then parse it yourself.
I agree. Here's the link:
subject: post parameter in sort of input ?
It's not a secret anymore!