In your client code, don't you need to include HTTP/1.0 or HTTP/1.1 on the request line? From RFC 2626:
Request-Line = Method SP Request-URI SP HTTP-Version CRLF
For example:
POST /servlets/SPostServlet HTTP/1.0
It looks like your client is just sending:
POST servlets/com.gtnet.RS.RS
with no HTTP-version value. If your request was hitting the servlet, but doPost() was not implemented, you should see the default "This method not implemented" page generated by HttpServlet. But you are seeing "Your browser sent a request that this server could not understand." That suggests to me you are not formulating the POST request correctly.
- Fernando
At 03:09 PM 12/15/99 +0000, you wrote:
Hi,
thanks for your reply.
My original code is actually using the PrintWriter class.
I found the BufferedWriter stuff on a java newsgroup, with the brash
claim that it worked !
Neither make any difference for the purposes of this.
As for sending a real HTML page, again, this made no differece.
My understanding is that I can post any text back.
thanks for your contribution.
why should my servlet not recognise/support the POST method ??
regards
pmi
Please Note that my original email had a typo in it,
and should have read as :
Hi,
1 Introduction
--------------
I am using the following builds:
Apache : 1.3.9, DSO support
JServ : cvs build Apache-JServ-19991123, latest stream
Solaris : 2.7
Notes
i. "com.gtnet.RS" is my package URL
ii. "socket" is my socket connection, and works fine for GET and DELETE
iii. "/servlets" is the directory containing the servlet - RS jar file.
iv. My host name is "lewis"
My servlet, RS, is a jar file, which I am able to call the HTTP GET and DELETE
methods, but a different story with the POST method.
2 Error Message
---------------
I am getting the following error message, which I'm directing to stdout:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
Bad Request
Your browser sent a request that this server could not understand.
Apache/1.3.9 Server at lewis Port 8080
3 Servlet doPost method
-----------------------
In my RS servlet, I do have a simple doPost method:
public void doPost( HttpServletRequest request,
HttpServletResponse response )
throws ServletException, IOException
{
// set content type and other response header fields first
response.setContentType("text/html");
// then write the data of the response
PrintWriter out = response.getWriter();
out.println("doPost" );
out.close();
}
4 Client Code
-------------
public void postFile( )
{
try {
String servlet = "/servlets/com.gtnet.RS.RS";
String content = "this is the contents";
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
bw.write("POST " + servlet);
bw.write("\n");
bw.write("Content-length:" + content.length());
bw.write("\n");
bw.write("\n");
bw.write(content);
bw.flush();
}
catch(IOException e)
{
;
}
}
5 Log Files
-----------
mod_jserv.log:
[15/12/1999 10:17:06:680] (ERROR) ajp12: Servlet Error: POST is not supported by this URL
access_log:
10.77.62.48 - - [15/Dec/1999:10:17:06 +0000] "POST /servlets/com.gtnet.RS.RS" 400 -
6 Help required
---------------
Does anyone know why the POST method is not being supported ?????
thanks
pmi