tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <wbar...@wilshire.com>
Subject Re: Parasite string length added in the message body
Date Sat, 01 Mar 2003 08:16:28 GMT
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" <raphael.bousquet@LTUtech.com> wrote in message
news:PHEILLNADHPMCNHCBGEFOEOKDBAA.raphael.bousquet@LTUtech.com...
> 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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message