tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Re: Tomcat/servlet question
Date Fri, 12 Sep 2008 21:23:22 GMT
André Warnier wrote:
> Hi.
> 
> In response to a request, a servlet opens and reads a file from disk,
> and sends the content out to the browser (ultimately), "as is".
> The content of the file is an html document, saved as a text under some
> encoding, correctly encoded under that encoding, and containing an html
> <meta http-equiv="Content-type: text/html; charset=xxxx >
> where the specified encoding is correct and matches the document's.
That's nice but it means nothing to the Servlet container.
> 
> The "in" stream (the disk file) is opened "raw", and the same for the
> "out" stream.
> 
> Question :
> who is responsible for setting the HTTP response headers ?
It varies, depending on the header.

> Does the servlet have to set them explicitly ?
Yes, kind of. You don't need to set the header directly but, for encoding
etc, you do need to call one of the methods that will cause it to be set.

>or does Tomcat do that
> itself if the servlet doesn't ? (*)
Tomcat will. The spec defines the defaults. The short version is
ISO-8859-1. You'll need to enable STRICT_SERVLET_COMPLIANCE to get 100%
spec compliant behaviour in this area. See
http://tomcat.apache.org/tomcat-6.0-doc/config/systemprops.html

> (I am specifically interested in headers like "Content-type" and
> "Content-length").
Content-type is the servlet's problem. Tomcat will normally look after
content-length.

> (*) and if Tomcat does, how does it know what to put there ?
The spec defines it.

If we were talking about the default servlet, the fileEncoding parameter
would also affect behaviour.

Mark



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message