aspose file tools*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: request.getParam...