DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=36814>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=36814

           Summary: Parameter for POST encoding
           Product: Tomcat 5
           Version: 5.5.9
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: [EMAIL PROTECTED]


There is a problem to convert the incoming request of a POST request to the
right character encoding. Mostly the browsers do not send the correct request
header so Tomcat falls back to the default encoding which is ISO-8859-1. But in
a multi language environment (e.g. mixture of english, european, chinese, etc.
languages) ISO-8859-1 is not sufficient and UTF-8 is more recommended.

To tell Tomcat to use e.g. UTF-8 as the default encoding I suggest to change the
source code of Request.java in the package org.apache.catalina.connector so that
the encoding is read from a context parameter:

/**
 * Return the character encoding for this Request.
 */
public String getCharacterEncoding() {
  String enc = coyoteRequest.getCharacterEncoding();
  if (enc == null) {
    return getDefaultPostEncoding();
  }
  return enc;
}

/**
 * Get the default encoding for parameters of requests with post method.
 */
private String getDefaultPostEncoding() {
  return context.getServletContext().getInitParameter("defaultPostEncoding");
}


To use this with UTF-8 encoding you have to add this to the <Context> of your
webapp:

<Parameter name="defaultPostEncoding" value="UTF-8"
           override="false"/>


What do you think? Is this a good enhancement for Tomcat? It would be great if
you could add this to the base code of Tomcat. Probably many Tomcat users would
be glad to have it, wouldn't they?

With regards

Udo Walker

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to