• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getReader()

 
Deepan Devadasan
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fellas,

I found shocking to learn something like this in one of the final mocks..

it said HttpServletRequest.getReader() can be used to get the parameters passed from a form...

So far i have header only about getParameter...

Can somebody please clarify the difference and suggest whether there are any other ways for the same cause..
 
Allen Mathew Williams
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
HttpServletRequest.getReader() returns the body of the request as a BufferedReader,with the characters encoded in the encoding specified in the request, while the getParameter will get value of the requested parameter as a String or return null of no such parameter exists.
Hope this sheds some light on your issue.

Allen.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65119
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can read the body of the request during an HTTP POST and parse the encoded parameters yourself, or let the request instance do it for you.

Unless you have a good reason to do it yourself, such as in a multi-part request, it's best to just use getParameter and its related methods.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Theepan Thevathasan:

it said HttpServletRequest.getReader() can be used to get the parameters passed from a form...


Get reader will give you a reader to the content that is there in the body of the HTTP request.In case of form with method=POST , the content are part of body of the HTTP request ,not URL.
 
Deepan Devadasan
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi buddies...

Great...

I will definitely not go wrong if i get it for the exam....

all the credits to the fellow ranchers.....

until i post a new question, bye
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic