This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "request.getParam..." Watch "request.getParam..." New topic


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);
System.out.println("line is 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??
Frank Carver

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 ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
It is sorta covered in the JavaRanch Style Guide.
subject: request.getParam...
Similar Threads
Servlet Applet Communication
passing parameters to servlets
How to propogate Configuration changes to different servers
Extract SOAP object from HttpServletRequest
How to make a repetitive URLConnection ?