From: remm Date: Wed, 27 Sep 2006 18:10:09 +0000 (+0000) Subject: - Take advantage of the compliance flag to add back forceful appending of the charset... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=1eae025334e877389f7797b173eddc290b02e415;p=tomcat7.0 - Take advantage of the compliance flag to add back forceful appending of the charset (for people who really wish to get in trouble). git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@450530 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/connector/Response.java b/java/org/apache/catalina/connector/Response.java index e643b1d92..0a82a71a9 100644 --- a/java/org/apache/catalina/connector/Response.java +++ b/java/org/apache/catalina/connector/Response.java @@ -38,6 +38,7 @@ import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletResponse; import org.apache.catalina.Context; +import org.apache.catalina.Globals; import org.apache.catalina.Session; import org.apache.catalina.Wrapper; import org.apache.catalina.security.SecurityUtil; @@ -602,6 +603,22 @@ public class Response throw new IllegalStateException (sm.getString("coyoteResponse.getWriter.ise")); + if (Globals.STRICT_SERVLET_COMPLIANCE) { + /* + * If the response's character encoding has not been specified as + * described in getCharacterEncoding (i.e., the method + * just returns the default value ISO-8859-1), + * getWriter updates it to ISO-8859-1 + * (with the effect that a subsequent call to getContentType() will + * include a charset=ISO-8859-1 component which will also be + * reflected in the Content-Type response header, thereby satisfying + * the Servlet spec requirement that containers must communicate the + * character encoding used for the servlet response's writer to the + * client). + */ + setCharacterEncoding(getCharacterEncoding()); + } + usingWriter = true; outputBuffer.checkConverter(); if (writer == null) {