tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From billbar...@apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/generators ErrorHandler.java
Date Sat, 31 May 2003 02:45:58 GMT
billbarker    2003/05/30 19:45:58

  Modified:    src/share/org/apache/tomcat/modules/generators
                        ErrorHandler.java
  Log:
  Localize the charset for all error handlers.
  
  Also change to always set the charset if it is available, since IMHO it is better to send
a charset then to assume that the browser defaults to iso-latin-1 (which is false for MSIE,
for example).
  
  This clearly needs to be done for Japanese servers.  It should be a pretty minor change
for en, fr, and sp servers.  Other Locals where probably just as broken before.
  
  Fix for bug #20361.
  Reported By: Gary gbraven@yahoo.com
  
  Revision  Changes    Path
  1.28      +27 -8     jakarta-tomcat/src/share/org/apache/tomcat/modules/generators/ErrorHandler.java
  
  Index: ErrorHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/generators/ErrorHandler.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- ErrorHandler.java	16 Oct 2002 06:03:39 -0000	1.27
  +++ ErrorHandler.java	31 May 2003 02:45:58 -0000	1.28
  @@ -485,7 +485,14 @@
   	throws Exception
       {
   	String msg=(String)req.getAttribute("javax.servlet.error.message");
  -	res.setContentType("text/html");	// ISO-8859-1 default
  +
  +	String charset = LocaleToCharsetMap.getCharset(Locale.getDefault());
  +	if (charset == null) {
  +	    res.setContentType("text/html");
  +	} else {
  +	    res.setContentType("text/html; charset=" + charset);
  +	    res.setUsingWriter(true);
  +	}
   
   	// "javax.servlet.include.request_uri" is set to this handler
   	String requestURI = req.requestURI().toString();
  @@ -591,7 +598,7 @@
   	// only include <head>...<body> if reset was successful
   	if ( needsHead ) {
              String charset = LocaleToCharsetMap.getCharset(Locale.getDefault());
  -           if (charset == null || charset.equalsIgnoreCase("ISO-8859-1"))
  +           if (charset == null)
                  res.setContentType("text/html");
              else {
                  res.setContentType("text/html; charset=" + charset);
  @@ -690,13 +697,18 @@
   	if( sc == 304 ) {
   	    //NotModified must not return a body
   	    return;
  -	} else {
  -	    // don't set a content type if we are answering If-Modified-Since.
  -	    // Proxy caches might update their cached content-type with this
  -	    // info (mod_proxy does it). Martin Algesten 15th Oct, 2002.
  +	} 
  +	// don't set a content type if we are answering If-Modified-Since.
  +	// Proxy caches might update their cached content-type with this
  +	// info (mod_proxy does it). Martin Algesten 15th Oct, 2002.
  +	String charset = LocaleToCharsetMap.getCharset(Locale.getDefault());
  +	if (charset == null) {
   	    res.setContentType("text/html");
  +	} else {
  +	    res.setContentType("text/html; charset=" + charset);
  +	    res.setUsingWriter(true);
   	}
  -
  +	
   	if( sbNote==0 ) {
   	    sbNote=req.getContextManager().getNoteId(ContextManager.REQUEST_NOTE,
   						     "StatusHandler.buff");
  @@ -815,7 +827,14 @@
   
   	if( debug>0) ctx.log("Redirect " + location + " " + req );
   
  -	res.setContentType("text/html");	// ISO-8859-1 default
  +	String charset = LocaleToCharsetMap.getCharset(Locale.getDefault());
  +	if (charset == null) {
  +	    res.setContentType("text/html");
  +	} else {
  +	    res.setContentType("text/html; charset=" + charset);
  +	    res.setUsingWriter(true);
  +	}
  +
   	res.setHeader("Location", location);
   
   	if( sbNote==0 ) {
  
  
  

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


Mime
View raw message