cvs commit: jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5 Constants.java CoyoteResponse.java
jfarcand2002/12/02 18:29:14 Modified:coyote/src/java/org/apache/coyote Response.java coyote/src/java/org/apache/coyote/tomcat5 Constants.java CoyoteResponse.java Log: Servlet 2.4 section 5.4 will be modified: A servlet should set the locale and the character encoding of a response. The locale is set using the ServletResponse.setLocale method, and communicated to the client using the Content-Language header. The character encoding can be set explicitly using the ServletResponse methods setCharacterEncoding and setContentType, or implicitly using the ServletResponse.setLocale method, and is communicated to the client using the charset parameter of the Content-Type header. Explicit specifications take precedence over implicit specifications. [...] The character encoding should be specified before the getWriter method of the ServletResponse interface is called; otherwise the default ISO-8859-1 is used. - That means if setContentType is called, then setLocale should do reset the content type. Same for setCharacterEncoding. If getWriter is called, then ignore any call to setContentType, setCharacterEncoding and setLocale. Please review. Revision ChangesPath 1.17 +10 -4 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Response.java Index: Response.java === RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Response.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- Response.java 9 Nov 2002 17:12:04 - 1.16 +++ Response.java 3 Dec 2002 02:29:14 - 1.17 @@ -91,8 +91,14 @@ // - Instance Variables + + +/** + * Default locale + */ +private static Locale DEFAULT_LOCALE = new Locale(en, US); - + /** * Status code. */ @@ -142,7 +148,7 @@ protected String contentLanguage = null; protected String characterEncoding = Constants.DEFAULT_CHARACTER_ENCODING; protected int contentLength = -1; -private Locale locale = null;//Constants.DEFAULT_LOCALE; +private Locale locale = DEFAULT_LOCALE; /** * Holds request error exception. @@ -311,7 +317,7 @@ // Reset the headers only if this is the main request, // not for included contentType = Constants.DEFAULT_CONTENT_TYPE; -locale = null;//Constants.DEFAULT_LOCALE; +locale = DEFAULT_LOCALE; contentLanguage = null; characterEncoding = Constants.DEFAULT_CHARACTER_ENCODING; contentLength = -1; @@ -525,7 +531,7 @@ contentType = Constants.DEFAULT_CONTENT_TYPE; contentLanguage = null; -locale = null;//Constants.DEFAULT_LOCALE; +locale = DEFAULT_LOCALE; characterEncoding = Constants.DEFAULT_CHARACTER_ENCODING; contentLength = -1; status = 200; 1.4 +1 -2 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5/Constants.java Index: Constants.java === RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5/Constants.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Constants.java10 Oct 2002 09:45:30 - 1.3 +++ Constants.java3 Dec 2002 02:29:14 - 1.4 @@ -58,8 +58,6 @@ */ package org.apache.coyote.tomcat5; -import java.util.Locale; - /** * Constants. * @@ -92,5 +90,6 @@ */ protected static final boolean SECURITY = (System.getSecurityManager() != null); + } 1.12 +50 -13 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5/CoyoteResponse.java Index: CoyoteResponse.java === RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5/CoyoteResponse.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- CoyoteResponse.java 11 Nov 2002 11:01:04 - 1.11 +++ CoyoteResponse.java 3 Dec 2002 02:29:14 - 1.12 @@ -261,7 +261,18 @@ */ protected boolean included = false; + +/** + * The characterEncoding flag + */ +private boolean isCharacterEncodingSet = false; + +/** + * The contextType flag + */ +private boolean isContentTypeSet = false; + /** * The error flag. */ @@ -313,6 +324,8 @@ appCommitted = false; included = false;
Re: cvs commit: jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5 Constants.java CoyoteResponse.java
I'm not really happy with having a default Locale in the o.a.c.Response. I'd like it better if o.a.c.tc5.CoyoteResponse set the default Locale in recycle. - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 02, 2002 6:29 PM Subject: cvs commit: jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5 Constants.java CoyoteResponse.java jfarcand2002/12/02 18:29:14 Modified:coyote/src/java/org/apache/coyote Response.java coyote/src/java/org/apache/coyote/tomcat5 Constants.java CoyoteResponse.java Log: Servlet 2.4 section 5.4 will be modified: A servlet should set the locale and the character encoding of a response. The locale is set using the ServletResponse.setLocale method, and communicated to the client using the Content-Language header. The character encoding can be set explicitly using the ServletResponse methods setCharacterEncoding and setContentType, or implicitly using the ServletResponse.setLocale method, and is communicated to the client using the charset parameter of the Content-Type header. Explicit specifications take precedence over implicit specifications. [...] The character encoding should be specified before the getWriter method of the ServletResponse interface is called; otherwise the default ISO-8859-1 is used. - That means if setContentType is called, then setLocale should do reset the content type. Same for setCharacterEncoding. If getWriter is called, then ignore any call to setContentType, setCharacterEncoding and setLocale. Please review. Revision ChangesPath 1.17 +10 -4 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Response.java Index: Response.java === RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Respon se.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- Response.java 9 Nov 2002 17:12:04 - 1.16 +++ Response.java 3 Dec 2002 02:29:14 - 1.17 @@ -91,8 +91,14 @@ // - Instance Variables + + +/** + * Default locale + */ +private static Locale DEFAULT_LOCALE = new Locale(en, US); - + /** * Status code. */ @@ -142,7 +148,7 @@ protected String contentLanguage = null; protected String characterEncoding = Constants.DEFAULT_CHARACTER_ENCODING; protected int contentLength = -1; -private Locale locale = null;//Constants.DEFAULT_LOCALE; +private Locale locale = DEFAULT_LOCALE; /** * Holds request error exception. @@ -311,7 +317,7 @@ // Reset the headers only if this is the main request, // not for included contentType = Constants.DEFAULT_CONTENT_TYPE; -locale = null;//Constants.DEFAULT_LOCALE; +locale = DEFAULT_LOCALE; contentLanguage = null; characterEncoding = Constants.DEFAULT_CHARACTER_ENCODING; contentLength = -1; @@ -525,7 +531,7 @@ contentType = Constants.DEFAULT_CONTENT_TYPE; contentLanguage = null; -locale = null;//Constants.DEFAULT_LOCALE; +locale = DEFAULT_LOCALE; characterEncoding = Constants.DEFAULT_CHARACTER_ENCODING; contentLength = -1; status = 200; 1.4 +1 -2 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5/Constant s.java Index: Constants.java === RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat 5/Constants.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Constants.java 10 Oct 2002 09:45:30 - 1.3 +++ Constants.java 3 Dec 2002 02:29:14 - 1.4 @@ -58,8 +58,6 @@ */ package org.apache.coyote.tomcat5; -import java.util.Locale; - /** * Constants. * @@ -92,5 +90,6 @@ */ protected static final boolean SECURITY = (System.getSecurityManager() != null); + } 1.12 +50 -13 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5/CoyoteRe sponse.java Index: CoyoteResponse.java === RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat 5/CoyoteResponse.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- CoyoteResponse.java 11 Nov 2002 11:01:04 - 1.11 +++ CoyoteResponse.java 3 Dec 2002 02:29:14 - 1.12 @@ -261,7 +261,18 @@ */ protected boolean included = false