• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to parse HTTP Post request

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone show with code how to parse POST request in JAVA and extract username ,password etc.

Thanks
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomcat obviously can do that; you could check its source code.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic