tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Jung <rainer.j...@kippdata.de>
Subject Re: DefaultServlet and default character encoding
Date Fri, 18 Jun 2010 10:50:31 GMT
On 18.06.2010 11:04, Felix Schumacher wrote:
> On Thu, 17 Jun 2010 19:32:36 +0400, Konstantin Kolinko
> <knst.kolinko@gmail.com>  wrote:
>> 2010/6/17 Felix Schumacher<felix.schumacher@internetallee.de>:
>>> For the moment I have written a filter, which sets a default encoding,
> as
>>> soon as Response.setContentType(String type) is called and
>>> type.startsWith("text/"). That works for the moment, but I would prefer
>>> the
>>> solution described in above thread.
>>
>> I know that setting charset in a mime-mapping works, e.g.:
>>
>>      <mime-mapping>
>>          <extension>htm</extension>
>>          <mime-type>text/html;charset=iso-8859-1</mime-type>
>>      </mime-mapping>
>>      <mime-mapping>
>>          <extension>html</extension>
>>          <mime-type>text/html;charset=iso-8859-1</mime-type>
>>      </mime-mapping>
>>
>> Note, that it would be better if the mime type set by a HTTP header
>> and the one provided by HTML tag match strictly (case sensitively).
>> Otherwise some browsers will start guessing.  IIRC, the HTML spec says
>> that the HTTP header takes precedence, but not all browsers follow it
>> strictly.
> I will look into this one.
>>
>> Also there is AddDefaultCharsetFilter in Tomcat 7. It is similar to
>> what you are doing, see its JavaDoc and source code.
> Yes, my filter looked like a twin, with the exception, that I called
> super.setCharacterEncoding(defaultEncoding) instead of manipulating the
> content-type directly (and of course that defaultEncoding is different to
> super.getCharacterEncoding() which would yield iso-8859-1).
> I could extend that filter to my needs. Should I file a enhancement
> request for that?
>>
>>
>>> apache httpd thinks it would be better to append a
>>> charset to the response
>>
>> I wonder, if there is a way to improve your Apache HTTPD configuration.
> I tried to let apache httpd now that in location /webapp the default
> charset was different from iso-8859-1. But mod_jk ignored my pledges :(
> Even so I think DefaultServlet should be able to set a charset if
> configured to.

How did you do that in Apache? Did you use

http://httpd.apache.org/docs/2.2/mod/core.html#adddefaultcharset

and if so, how exactly?

You can switch JkLogLevel on a system with low load to "debug", then 
mod_jk will log all response headers it received from Tomcat.

mod_jk itself takes the Content-Type header received from tomcat, 
extracts its full value and applies it to the Apache response via 
ap_set_content_type(). Apache later applies any configured default 
charset via ap_http_header_filter() in ap_http_header_filter(). At least 
that's what I expect to happen.

Regards,

Rainer

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


Mime
View raw message