You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tony LaPaso <tl...@attbi.com> on 2002/08/09 17:27:19 UTC

??? Bug in Tomcat Response Headers ???

Hello all,

I posted this a few days ago but received no response....If
someone intimately familiar with Tomcat internals (liek Craig M.)
could comment I'd appreciate it.

I'm not 100% sure about this but I think I found a problem with
the way Tomcat encodes characters. First I'll explain what I
think the problem is and then I'll say why I think it's a
problem. Please keep in mind that I'm not looking for alternative
solutions (i.e., please don't tell me to use UTF-8). I want to
stay focused on the problem. The behavior I'm seeing is not
correct, IMHO.

Assume I have these three lines of code in my doGet():

response.setContentType("text/html;charset=UTF-16");
PrintWriter pw = response.getWriter();
pw.print("<html><head><title>Test</title>" +
         "</head><body></body></html>");

The PrintWriter returned from response.getWriter() will encode
all characters as UTF-16. This means that all the response body
(i.e., the HTML) gets encoded as UTF-16 before being sent to the
client. So far, so good.

Here's the problem: The reponse headers generated from the
servlet *ALSO* get encoded as UTF-16, which, I believe is in
violation of the HTTP spec. In reading the HTTP spec, response
headers should be encoded as US-ASCII.

So, it seems that Tomcat (or perhaps the Servlet API
implementation) needs to be modified so that the response headers
are *always* encoded as US-ASCII, regardless of the encoding for
the response body.

Again, please do not offer "ways around" this or ask me why I'm
sending UTF-16 encoded characters. I know UTF-8 can be used but
that's not the point.

Is this a bug or am I buggy?

Thanks,



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>