• Post Reply Bookmark Topic Watch Topic
  • New Topic

getInputStream() vs getParameter()  RSS feed

 
Reema Patel
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I believe that the getInputStream() method is used to read binary data (e.g. file upload) whereas, the getParameter() method is used to retrieve request parameters. And, you can use only use one of there in a single servlet.

Is there any other difference btw these two methods?

Thanks,
Reema
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best place to look for finding the difference between two methods is the API.
This page contains a full description of each of these methods.
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletRequest.html
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One significant difference is that you can get at the parameters through getInputStream, but you can't get the InputStream if you're accessing parameters.

You would use only one or the other, as their uses cases are different.
 
Jaime M. Tovar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The methods are in ServletRequest Interface, the inputstream is to work over raw data, the getParameter is when you only want to get a parameter. I remember it is not recommended to use both methods over the same request cause you can get weird behavior
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!