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 [EMAIL PROTECTED] changed: What|Removed |Added Status|REOPENED|RESOLVED Resolution||INVALID --- Additional Comments From [EMAIL PROTECTED] 2004-02-07 14:28 --- The Filter is setting the content type, but then the JSP is next in the pipeline and then sets the content type overriding what was set by the filter. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
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 [EMAIL PROTECTED] changed: What|Removed |Added CC||[EMAIL PROTECTED] --- Additional Comments From [EMAIL PROTECTED] 2004-02-07 15:04 --- *** Bug 11197 has been marked as a duplicate of this bug. *** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
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 --- Additional Comments From [EMAIL PROTECTED] 2002-11-04 14:15 --- A possible fix for this: 1) If you are using a filter, wrap your response in a response wrapper that does not allow the content-type to be set by the page. The code for this is: The following filter works: /** * @author a href=mailto:scott;atlassian.comScott Farquhar/a */ public class EncodingFilter implements Filter { public void destroy() { } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { servletRequest.setCharacterEncoding(UTF-8); servletResponse.setContentType(text/html;charset=UTF-8); filterChain.doFilter(servletRequest, new HttpServletResponseWrapper((HttpServletResponse) servletResponse) { public void setContentType(String s) { System.out.println(EncodingFilter.setContentType + s); new Throwable().printStackTrace(); if (s.length() text/html.length() s.charAt(0) == 't' s.startsWith(text/html)) { //do nothing. 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. //And besides, this is the way that we do it in JIRA, and I want to test this against different //servers } else { super.setContentType(s); } } }); System.out.println(servletResponse.getCharacterEncoding() = + servletResponse.getCharacterEncoding()); } public void init(FilterConfig filterConfig) throws ServletException { } } -- To unsubscribe, e-mail: mailto:tomcat-dev-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-dev-help;jakarta.apache.org
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 [EMAIL PROTECTED] changed: What|Removed |Added Status|RESOLVED|REOPENED Resolution|WORKSFORME | --- Additional Comments From [EMAIL PROTECTED] 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: mailto:tomcat-dev-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-dev-help;jakarta.apache.org
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 [EMAIL PROTECTED] changed: What|Removed |Added Status|NEW |RESOLVED Resolution||WORKSFORME Summary|response.setContentType() in|response.setContentType() in |Filter.doFilter not changed |Filter.doFilter not changed |content type|content type --- Additional Comments From [EMAIL PROTECTED] 2002-02-12 23:24 --- If you're using this before the response is committed, then it should work. It probably won't do any good to set it after calling doFilter (but that depends on what your servlet is doing). -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]