For the observant,  you will notice the header 'Transfer-Encoding: chunked'.
In this case, the HTTP/1.1 protocol requires that the server sends the
length of the chunk prior to sending the body of the chunk itself.

If you don't want to see this, simply set the content-length header (e.g.
response.setContentLength) before sending the output from your servlet.

"Raphael Bousquet" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Does someone know why Tomcat (version 4.1.18 Linux and Windows) adds the
> string length in the message body?
>
> Here is what I receive from Tomcat:
> --------------------------------------------------
> HTTP/1.1 200 OK
> Content-Type: text/xml
> Transfer-Encoding: chunked
> Date: Fri, 28 Feb 2003 16:59:22 GMT
> Server: Apache Coyote/1.0
> Connection: close
>
> 56
> <?xml version="1.0"?>
> <book>
> <author>Mike</author>
> </book>
>
> 0
>
> --------------------------------------------------
> as you can see the message body contains a '56' and a '0', and I don't
know
> where they come from? 56 is the size of the string "<?xml ... /book>" in
> hex.
>
> Here is the code of my servlet:
> --------------------------------------------------
> package testservlet;
>
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> public class Reply
> extends HttpServlet
> implements SingleThreadModel
> {
> private static final String CONTENT_TYPE = "text/xml";
>
> //Process the HTTP Get request
> public void doGet(HttpServletRequest request, HttpServletResponse
response)
> throws ServletException, IOException
> {
> //partner identifier
> response.setContentType(CONTENT_TYPE);
> PrintWriter out = response.getWriter();
> out.println("<?xml version=\"1.0\"?>");
> out.println("<book>");
> out.println("<author>Mike</author>");
> out.println("</book>");
> out.flush();
> out.close();
> }
> }
> --------------------------------------------------
>
> It is very simple and there is no sign of any string length being written
in
> the output stream.
>
> Is this normal? If I am missing something I would really appreciate your
> input. Thanks




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to