Hi,
I am trying to write an application program in java that makes a post
request to a servlet. The servlet seems to service the request fine except
it fails to read the parameter I am passing. The following is the piece of
the application code. Could some one tell me how I should format headers to
pass parameters to the servlet.
Appreciating your help,
Prasad
String sdata = "Hello";
//Http Header
dataout.writeBytes("POST /servlet/myTest HTTP/1.0\r\n");
dataout.writeBytes("Content-type: " + ctype + "\r\n");
dataout.writeBytes("Content-length: " + (sdata.length()) + "\r\n");
dataout.writeBytes("\r\n"); // end of header
// POST data
dataout.writeBytes(sdata);
The output from the servlet is as follows
HTTP/1.1 200 OK
Server: JavaWebServer/1.1.3
Content-Type: text/html
Connection: close
Date: Sun, 04 Apr 1999 07:21:34 GMT
<HTML>
<TITLE>Testing parameters </TITLE>
java.lang.NullPointerException:
at myTest.doPost(myTest.java:17)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:521)
at javax.servlet.http.HttpServlet.service(Compiled Code)
at com.sun.server.ServletState.callService(Compiled Code)
at com.sun.server.ServletManager.callServletService(Compiled Code)
at com.sun.server.http.InvokerServlet.service(InvokerServlet.java:101)
at javax.servlet.http.HttpServlet.service(Compiled Code)
at com.sun.server.ServletState.callService(Compiled Code)
at com.sun.server.ServletManager.callServletService(Compiled Code)
at com.sun.server.webserver.HttpServiceHandler.handleRequest(Compiled Code)
at com.sun.server.webserver.HttpServiceHandler.handleRequest(Compiled Code)
at com.sun.server.HandlerThread.run(Compiled Code)
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html