You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2002/11/02 19:24:33 UTC

DO NOT REPLY [Bug 5715] - response.setContentType() in Filter.doFilter not changed content type

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5715>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5715

response.setContentType() in Filter.doFilter not changed content type

scott@atlassian.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |



------- Additional Comments From scott@atlassian.com  2002-11-02 18:24 -------
Currently, when a JSP is compiled to java code, it includes a line such as:

  response.setContentType("text/html;charset=ISO-8859-1");

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:

  servletRequest.setCharacterEncoding("UTF-8");
  servletResponse.setContentType("text/html;charset=UTF-8");

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.

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.

Scott
-- 
ATLASSIAN - http://www.atlassian.com
Expert J2EE Software, Services and Support
-------------------------------------------------------
Need a simple, powerful way to track and manage issues?
Try JIRA - http://www.atlassian.com/software/jira

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