aspose file tools*
The moose likes Servlets and the fly likes getReader() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "getReader()" Watch "getReader()" New topic
Author

getReader()

Deepan Devadasan
Ranch Hand

Joined: Jan 25, 2007
Posts: 226
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..


Theepan Thevathasan
SCJP 1.4, SCWCD 1.4, SCMAD 1.0 SCBCD 1.3, MCP(.Net Frm 2.0 App Dev Fdn)
Allen Mathew Williams
Greenhorn

Joined: Jan 30, 2007
Posts: 8
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

Joined: Jan 10, 2002
Posts: 61420
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
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.


Rahul Bhattacharjee
LinkedIn - Blog
Deepan Devadasan
Ranch Hand

Joined: Jan 25, 2007
Posts: 226
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getReader()