tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Farquhar <>
Subject Setting Content Type in Servlet Filter fails
Date Sat, 02 Nov 2002 18:08:20 GMT

Currently, when a JSP is compiled to java code, it includes a line such as:


However, this seems to preclude setting the content type in a servlet 
filter, as anything that is set in the filter is over-ridden by the JSP. 
  Eg, with our product JIRA - we must cater for many different character 
sets, and so we can't hard-code the characterset in the header of the 
JSP, and must set it at runtime.

To do so, we use a filter that does this:


Which works fine on Orion and Resin.  But fails on Tomcat and Jetty 
(presumably because they share the same JSP compilation engine).

You can't set it after the JSP has been called, because by then the 
response has been committed, and you can't set headers after that time.

There is already a bug raised in bugzilla for this:

Any ideas on how to fix it?  Could you make setContentType immutable? 
So only allow it to be set once?  Else change the JSP compiler so that 
it checks if contentType has already been set before setting it?

This prevents JIRA running on Tomcat with configurable charactersets, 
and presumably other applications are in the same position.

Thanks for your time.



Expert J2EE Software, Services and Support
Need a simple, powerful way to track and manage issues?
Try JIRA -

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message