• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to parse HTTP Post request  RSS feed

 
ananda sankar roy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone show with code how to parse POST request in JAVA and extract username ,password etc.

Thanks
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat obviously can do that; you could check its source code.
 
Deepak Kaimal
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that you are somehow getting POST request contents without having access to the HTTPServletRequest object. In such a case one of the easier libraries to use is the Jakarta Commons FileUpload. Try using the MultiPartStream class, if required in conjunction with ParameterParser. The API docs can be found at http://jakarta.apache.org/commons/fileupload/apidocs/index.html
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you need to do this in plain old Java or in a servlet container? I've done it in plain old Java. I import and use nothing that doesn't come in the JRE. It was entertaining right up to multi-part mime request and then it got tedious.
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you'd look at the syntax of POST data, you'd see that it can be done with two StringTokenizers, the outer one with delimiter '&' and the inner one with "=".
The strings will probably have to be decoded Ie + and &xx restored to whatever.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!