struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton" <niall.pember...@blueyonder.co.uk>
Subject Re: [PATCH] patch for bug 29824
Date Sat, 03 Jul 2004 11:19:33 GMT
The bug is marked as "RESOLVED/FIXED" so its unlikely anyone would ever look
at it. If someone has marked it as "resolved" by mistake then you should
re-open it.

Niall

----- Original Message ----- 
From: "KUROSAKA Teruhiko" <kuro@bhlab.com>
To: "Struts Developers List" <dev@struts.apache.org>
Sent: Saturday, July 03, 2004 8:32 AM
Subject: [PATCH] patch for bug 29824


> Hello,
> I made a patch for the bug I submitted 29824,
> http://issues.apache.org/bugzilla/show_bug.cgi?id=29824
> and I attached the patch with the bug report a week ago.
> But I don't see it being integrated.  Should I just wait
> to see some comitter to pick it up, or do I need to ask
> for it?  I'm attaching the patch with this email.
>
> -- 
> KUROSAKA ("Kuro") Teruhiko, San Francisco, California, USA
> Internationalization Consultant --- now available for new contracts!
> http://www.bhlab.com/
>
>
>
>
>
>
>


----------------------------------------------------------------------------
----


> --- 
../../../refsrc/jakarta-struts-1.1-src/src/share/org/apache/struts/action/Re
questProcessor.java Mon Jun 30 04:50:50 2003
> +++ src/share/org/apache/struts/action/RequestProcessor.java Sun Jun 27
04:48:03 2004
> @@ -233,6 +233,9 @@
>          processContent(request, response);
>          processNoCache(request, response);
>
> +        // Set the encoding of the request (parameter) if requested
> +        processRequestEncoding(request, response);
> +
>          // General purpose preprocessing hook
>          if (!processPreprocess(request, response)) {
>              return;
> @@ -510,6 +513,34 @@
>
>      }
>
> +
> +    /**
> +     * <p>Set the character encoding as which the incoming request should
> +     * be interpreted.  This method uses the value specified as the
> +     * <code>requestEncoding</code> attribute of the &lt;controller>
tag.
> +     * Requests are usually encoded in the same character encoding
> +     * of the HTML form, so that encoding should be specified.
> +     * See {@link org.apache.struts.config.ControllerConfig}
documentation
> +     * for further details.</p>
> +     * @param request The servlet request we are processing
> +     * @param response The servlet response we are creating (dummy --- 
not used)
> +     * @exception ServletException if thrown by
HttpServletRequest.setCharacterEncoding()
> +     * @since Struts 1.2
> +     */
> +    protected void processRequestEncoding(HttpServletRequest request,
> +                                  HttpServletResponse response)
> +        throws  ServletException{
> +
> +        String reqEnc =
moduleConfig.getControllerConfig().getRequestEncoding();
> +        if (reqEnc != null) {
> +     try{
> + request.setCharacterEncoding(reqEnc);
> +     }catch(java.io.UnsupportedEncodingException uex){
> + throw new ServletException(uex);
> +     }
> +        }
> +
> +    }
>
>      /**
>       * Ask our exception handler to handle the exception.  Return the
> --- 
../../../refsrc/jakarta-struts-1.1-src/src/share/org/apache/struts/config/Co
ntrollerConfig.java Mon Jun 30 04:51:52 2003
> +++ src/share/org/apache/struts/config/ControllerConfig.java Sun Jun 27
05:10:52 2004
> @@ -124,6 +124,49 @@
>          this.contentType = contentType;
>      }
>
> +    /**
> +     * <p>The character encoding in which each request is encoded.
> +     * Requests are usually encoded in the same character encoding
> +     * of the HTML form, so that encoding should be specified.</p>
> +     *
> +     * <p>You <strong>must</strong> specify the encoding one way or
the
other
> +     * in order for ActionForm to be able to interpret requests encoded
in
> +     * any encoding other than ISO-8859-1, including
<strong>UTF-8</strong>.</p>
> +     *
> +     * <p> This nonsense is because major web browsers do not
> +     * add charset parameter in the Content-Type headers of the requests
> +     * they generate, for probably historical reasons.</p>
> +     *
> +     * <p>Having a character encoding in the configuration file has an
obvious
> +     * limitation; only one character encoding can be specified
> +     * for the entire module. This limitation virtually means
> +     * a <strong>multi-locale application must use the UTF-8
encoding</strong>, unless
> +     * all the locales it supports can be based on a traditional encoding
> +     * (like French and German).
> +     * For example,  if an application needs to supports the French
> +     * locale (which traditionally uses the ISO-8859-1 encoding) and
> +     * the Japanese locale (Shift_JIS), then the application must
> +     * use UTF-8 encoding instead.  If this is going to be a problem
> +     * and if you wish to switch the encoding according to the current
locale,
> +     * consider calling request.setCharacterEncoding() by yourself
> +     * from reset() of ActionForm subclasses, instead of using
> +     * this requestEncoding attribute.</p>
> +     *
> +     * @since Struts 1.2
> +     */
> +    protected String requestEncoding = null; // Let container decide
(Most likely ISO-8859-1)
> +
> +    public String getRequestEncoding() {
> +        return (this.requestEncoding);
> +    }
> +
> +    public void setRequestEncoding(String requestEncoding) {
> +        if (configured) {
> +            throw new IllegalStateException("Configuration is frozen");
> +        }
> +        this.requestEncoding = requestEncoding;
> +    }
> +
>
>      /**
>       * The debugging detail level that determines logging verbosity.
> @@ -377,6 +420,10 @@
>              sb.append(",contentType=");
>              sb.append(this.contentType);
>          }
> +        if (this.requestEncoding != null) {
> +     sb.append(",requestEncoding=");
> +     sb.append(this.requestEncoding);
> + }
>          if (this.forwardPattern != null) {
>              sb.append(",forwardPattern=");
>              sb.append(this.forwardPattern);
> --- 
../../../refsrc/jakarta-struts-1.1-src/web/blank/WEB-INF/struts-config.xml
Mon Jun 30 04:51:22 2003
> +++ web/blank/WEB-INF/struts-config.xml Sat Jun 26 06:55:22 2004
> @@ -264,10 +264,17 @@
>
>  <!-- ===================================== Controller Configuration -->
>
> -
> +<!-- 
> +    Use requestEncoding attribute to specify the character encoding
> +    of the request, if it is not ISO-8859-1.  The request's
> +    character encoding is usually the same as the encoding of the
> +    form that submits the request, which is typically specified
> +    in JSP using the page directive's contentType option, as in:
> +    <%@ page contentType="text/html; charset=UTF-8" %>
> +-->
>
>      <controller
> -
> +       requestEncoding="UTF-8"
>         processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
>
>
> --- ../../../refsrc/jakarta-struts-1.1-src/web/blank/pages/Welcome.jsp Mon
Jun 30 04:52:18 2003
> +++ web/blank/pages/Welcome.jsp Sat Jun 26 06:54:06 2004
> @@ -1,3 +1,4 @@
> +<%@ page contentType="text/html; charset=UTF-8" %>
>  <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
>  <%@ taglib uri="/tags/struts-html" prefix="html" %>
>  <%@ taglib uri="/tags/struts-logic" prefix="logic" %>
> --- 
../../../refsrc/jakarta-struts-1.1-src/doc/userGuide/building_controller.xml
Mon Jun 30 04:51:36 2003
> +++ doc/userGuide/building_controller.xml Sat Jun 26 06:23:54 2004
> @@ -18,6 +18,7 @@
>      <author>David Graham</author>
>      <author>Tim O'Brien</author>
>      <author>Phil Steitz</author>
> +    <author>KUROSAKA "Kuro" Teruhiko</author>
>  </properties>
>
>  <body>
> @@ -201,6 +202,17 @@
>          <td>
>          If appropriate, set the following response headers: "Pragma",
>          "Cache-Control", and "Expires".
> +        </td>
> +    </tr>
> +
> +    <tr>
> +        <td>
> +        <code>processRequestEncoding</code>
> +        </td>
> +        <td>
> +        If the attribute is specified in the controller tag,
> +        the specified character encoding is used in interpretation of
> +        all requests.
>          </td>
>      </tr>
>
> --- ../../../refsrc/jakarta-struts-1.1-src/doc/userGuide/configuration.xml
Mon Jun 30 04:51:12 2003
> +++ doc/userGuide/configuration.xml Sat Jun 26 06:30:46 2004
> @@ -13,6 +13,7 @@
>      <author>Yann Cebron</author>
>      <author>David Graham</author>
>      <author>Tim O'Brien</author>
> +    <author>KUROSAKA "Kuro" Teruhiko</author>
>  </properties>
>
>  <body>
> @@ -103,6 +104,13 @@
>          May be overridden by the Action, JSP, or other resource to which
>          the request is forwarded.
>          [text/html] (optional)
> +        </li>
> +
> +        <li>
> +        <b>requestEncoding</b> - Character encoding used for parsing
> +        all requests.  This usually should match with the encoding of
> +        the originating forms.
> +        [ISO-8859-1] (optional)
>          </li>
>
>          <li>
>
>
>


----------------------------------------------------------------------------
----


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



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


Mime
View raw message