• Post Reply Bookmark Topic Watch Topic
  • New Topic

solution for http post  RSS feed

 
Ansari Raffik
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell me which one of the below is a better solution with regard to handling http posts.

In a servlet which needs to handle http posts is it better to use request.getReader or request.getInputStream for getting the input from the calling client..?

Thanks in advance
 
Chris Beckey
Ranch Hand
Posts: 116
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That depends on whether you are reading character data like form posts (use request.getReader) or reading binary data in a file upload (use request.getInputStream).
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not a typical getParameter()?
Just curious, if there is any rational reason behind it.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, unless you have a special situation, such as a multi-part post, it's not customary to parse the post body in servlet code.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!