InfoCenter Home > 4.2.9: Setting language encoding in Web applicationsThis article provides tips and guidelines for using various lanaguage encodings in WebSphere applications. Viewing encoded output streamsThe correct encoding must be used for sending characters from a servlet or JSP file to a Web browser. If Double Byte Character Set (DBCS) output streams are not being displayed correctly in Web browser clients accessing applications in the WebSphere Application Server environment, consider the following solutions. Configure application serversTo configure an entire application server to use a particular encoding, add the following command line argument to the application server: -Ddefault.client.encoding=encodingwhere encoding is the encoding of your choice. The default value of default.client.encoding is "UTF-8". Specify encodings for particular JSP files or servletsTo specify the character encoding of the resulting stream, insert the encoding statement in the JSP file: <%@ page contentType="encoding %>where encoding is the encoding of your choice. For a servlet, add the statement: HttpServletResponse.setContentType("text/html;charset=Big5"); The above example assumes that you want to use the Big5 character set to encode your servlet output. You can substitute a different encoding. Run the entire product in a locale that supports the encodingWebSphere Application Server can be run in the locale which supports that encoding. For instance, it can be run in the zh-TW (Traditional Chinese Locale) which supports the Big5 encoding. Specify the locale when you install IBM WebSphere Application Server. Check the browser and operating system supportTo display encoded characters in your browser, a user must install the support for that language on his or her operating system. For Windows NT, accomplish this by opening Internet Explorer and clicking Tools -> Windows Update. This will take you to the Windows Update site, which provides a list of languages for which you can install support on your machine. From the list, select the languages that you want your system to support. Writing to and from databasesWhen writing data to a database, a servlet (or other application component) must use the same encoding as that data stored in the database. Similarly, the database and a servlet obtaining data from the database must use the same encoding. For example, a servlet writing data in a Korean encoding cannot write the data into a database configured with an English encoding, unless the servlet first converts the data to an English encoding. The same is true of any two encodings. |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|