Passing Japanese and other UTF8 characters to a servlet in WebSphere® Application Server via HTTP request

Technote (FAQ)
Problem
In order to pass Japanese and other UTF8 characters to a servlet via a HTTP request (GET or POST), you must set a JVM parameter within the WebSphere Application Server: -Ddefault.client.encoding=<encoding type>
Solution
Customer Problem:
Application sends Japanese data with a POST or GET to a servlet. The servlet retrieves the values of the parameters using either HttpUtils.parseQueryString() or HttpServletRequest.getParameter(). In both cases the data is not returned as Japanese, but an empty string or a series of '?' characters.

There are cases where Japanese data is sent to the server in the HTTP body. In these cases, the data is read from the HttpServletRequest input stream based on the content encoding sent by the browser (such as, Content-Type ... charset=UTF8). When the encoding is set to read Japanese from the input stream, all the Japanese data is returned correctly.

Solution:
By using the JVM parameter
-Ddefault.client.encoding=UTF8
for the Application Server, Japanese characters are processed correctly. In WebSphere Application Server V4.0.x, this parameter's name has been changed to "client.encoding.override". These two parameters only apply to REQUEST headers, not to RESPONSE headers. RESPONSE headers must be defined in code for servlets or via the JSP "file.encoding" parameter.

To add the JVM parameter to WebSphere Application Server V3.5.X

  1. Open the adminclient
  2. Navigate to the appserver and select it
  3. In the "Command line Arguments" field enter:
    -Ddefault.client.encoding=UTF8
  4. Choose "OK"
  5. Choose "apply"
  6. Restart the appserver

To add the JVM parameter to WebSphere Application Server V4.0.X
  1. Open up the adminclient
  2. Navigate to the appserver and select it
  3. Click on the "JVM Settings" tab
  4. Click on the "Advanced JVM Settings" button
  5. In the "Command line arguments" field enter:
    -Dclient.encoding.override=UTF8
  6. Choose "OK"
  7. Choose "apply"
  8. Restart the appserver











Document Information

Product categories: Software, Application Servers, Distributed Application & Web Servers, WebSphere Application Server, Servlet Engine/Web Container
Operating system(s): Multi-Platform
Software version: 3.5, 4.0
Software edition: Standard, Advanced
Reference #: 1008783
IBM Group: Software Group
Modified date: 2004-03-15