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 2003/03/27 06:26:32 UTC

DO NOT REPLY [Bug 15944] - Compiled JSP page includes default setContentType() Call when not specified in the JSP page.

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=15944>.
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=15944

Compiled JSP page includes default setContentType() Call when not specified in the JSP page.





------- Additional Comments From scott@atlassian.com  2003-03-27 05:26 -------
You need to use a servlet filter to hide the call to setContentType().  Use
something like:

       filterChain.doFilter(servletRequest,
                new HttpServletResponseWrapper((HttpServletResponse)
servletResponse)
                {
                    public void setContentType(String s)
                    {
                        int index = -1;

                        if ((index = s.indexOf(';')) != -1)
                        {
                            String contentType = s.substring(0, index) +
";charset=" + getEncoding();
                            //This call could be trying to set the charset to
another charset.
                            //This is the case with Tomcat & Jetty, whose JSP
compiler sets the charset, whether it
                            //is specified in the JSP page or not.

                            //NB - this can also be accomplished by setting the
charset manually in the JSP page & the decorator,
                            //but this approach allows for run-time flexibility
of choosing the charsets.
                            super.setContentType(contentType);
                        }
                        else
                        {
                            super.setContentType(s);
                        }
                    }

                });

Cheers,
Scott

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