Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

post parameter in sort of input ?

 
heiner weilandt
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
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.
heiner
 
Dominic Paquette
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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
Dominic
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic