jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu...@apache.org
Subject cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt RequestEncodingSupport.java
Date Mon, 01 Apr 2002 20:24:06 GMT
luehe       02/04/01 12:24:06

  Modified:    standard/src/org/apache/taglibs/standard/tag/common/fmt
                        RequestEncodingSupport.java
  Log:
  Fixed 7670: <fmt:requestEncoding> with no value attribute specified
  doesn't set the character encoding properly based on the spec.
  
  Revision  Changes    Path
  1.4       +21 -13    jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/RequestEncodingSupport.java
  
  Index: RequestEncodingSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/RequestEncodingSupport.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RequestEncodingSupport.java	1 Feb 2002 01:16:47 -0000	1.3
  +++ RequestEncodingSupport.java	1 Apr 2002 20:24:06 -0000	1.4
  @@ -79,6 +79,12 @@
   
   
       //*********************************************************************
  +    // Private constants
  +
  +    private static final String DEFAULT_ENCODING = "ISO-8859-1";
  +
  +
  +    //*********************************************************************
       // Protected state
   
       protected String value;                      // 'value' attribute
  @@ -101,21 +107,23 @@
       // Tag logic
   
       public int doEndTag() throws JspException {
  -	if ((value == null)
  -	      && (pageContext.getRequest().getCharacterEncoding() == null)) {
  -	    /*
  -	     * no charset specified in tag or defined in request Content-Type
  -	     * header
  -	     */
  -	    value = (String) pageContext.findAttribute(REQUEST_CHAR_SET);
  +	if (value == null) {
  +	    // Use charset from request's Content-Type header
  +	    value = pageContext.getRequest().getCharacterEncoding();
  +	    if (value == null) {
  +		// Use charset from scoped attribute
  +		value = (String) pageContext.findAttribute(REQUEST_CHAR_SET);
  +		if (value == null) {
  +		    // Use default encoding
  +		    value = DEFAULT_ENCODING;
  +		}
  +	    }
   	}
   
  -	if (value != null) {
  -	    try {
  -		pageContext.getRequest().setCharacterEncoding(value);
  -	    } catch (UnsupportedEncodingException uee) {
  -		throw new JspTagException(uee.getMessage());
  -	    }
  +	try {
  +	    pageContext.getRequest().setCharacterEncoding(value);
  +	} catch (UnsupportedEncodingException uee) {
  +	    throw new JspTagException(uee.getMessage());
   	}
   
   	return EVAL_PAGE;
  
  
  

--
To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>


Mime
View raw message