wood burning stoves*
The moose likes Servlets and the fly likes request.getParam... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "request.getParam..." Watch "request.getParam..." New topic
Author

request.getParam...

ray bond
Ranch Hand

Joined: Oct 11, 2000
Posts: 111

hello there , I have an applet which post data to servlet at
"http://localhost/servlet/PostServlet?adclient=sun" url , then in servlet
I obtain "adclient" parameter , servlet code is like below ,

String clientparam = request.getParameter("adclient");
ServletInputStream servletinputstream = request.getInputStream();
DataInputStream datainputstream = new DataInputStream(servletinputstream);
if(datainputstream.readLine==null)
{
System.out.println("line is null");
}
while((strclient=datainputstream.readLine())!=null)
{
when I run applet they post data to servlet but servlet gives error "null pointer exception "
and also prints "line is null" which means datainputstream.readLine is null, if I take out code line ,
String clientparam = request.getParameter("adclient");
from servlet code then it works fine and without any error it gets all posted data
from applet and writes in the file , what could be the problem??
thanks.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
because POST parameters are passed in the body of the request, calling the method getParameter() automatically reads and parses the request body. If you need to read it yourself, you mustn't call getParameter().


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: request.getParam...
 
Similar Threads
passing parameters to servlets
How to propogate Configuration changes to different servers
Servlet Applet Communication
How to make a repetitive URLConnection ?
Extract SOAP object from HttpServletRequest