tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jilles van Gurp <incom...@jillesvangurp.com>
Subject Re: Default Charset in Content-Type Header
Date Thu, 22 Sep 2005 11:08:55 GMT
Alpay Ozturk wrote:
> Hi,
>
> I am using Tomcat 4.1.29 in a production environment and I want   tomcat
> not to add default charset in Content-Type response header.
> Is it possible?
>
> Thanks in advance.
>
> Alpay 
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
>   
No, it's not possible for text/* types. Tomcat will set a default 
charset if you don't set it yourself. For jsps you can change the 
default encoding by overriding it in your web.xml (see conf/web.xml for 
the defaults).

BTW I suspect you might be wanting this because you are trying to set 
the content type twice: first to text/html (tomcat will set a charset 
automatically because the servlet spec says text/html should be 
accompanied by a charset) and then to application/pdf (you end up with 
content-type: application-pdf; charset=utf-8). We ran into this issue 
before: you can't get rid of the charset once it is set and you need to 
set a content-type before you start streaming content.

The only thing you might be able to do is to filter the http header with 
apache or something. Trying to correct this from a servlet filter is 
tricky because the headers are streamed to the client before the 
content. The only way to work around this is to wrap the response and 
buffer the output, set the header in the real response and the stream 
the buffered content (tomcat will still set a default charset if the 
type is text/*).

The best solution is to simply accept that the charset needs to be set 
correctly for text/* and to do that yourself.

Jilles

---------------------------------------------------------------------
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