How to solve Chinese display garbled characters in WebLogic Server

Source: Internet
Author: User
Because operating systems, browsers, databases, and JVM use different character sets, applications developed based on WebLogic Server often encounter Chinese display garbled characters, in fact, the Web applications running on WebLogic Server have many settings related to character sets. The following is a summary. In order to correctly process Chinese characters, it is best to set these settings.

1. Add the JSP File Header
<% @ Page contenttype = "text/html; charset = GBK" %>
Specifies the character set used by the JSP.

2. Add the following content to the <JSP-Descriptor> file of weblogic. xml:
<JSP-param>
<Param-Name> encoding </param-Name>
<Param-value> GBK </param-value>
</JSP-param>
Specifies the character set used in the JSP file. <% @ page contenttype = "text/html; charset = GBK" %> In the JSP file overwrites this setting.

3. In the weblogic. xml file <JSP-Descriptor>, add
<JSP-param>
<Param-Name> compilersupportsencoding </param-Name>
<Param-value> true </param-value>
</JSP-param>
If this parameter is set to true, it specifies that
<% @ Page contenttype = "text/html; charset = GBK" %> or the character set defined in the encoding parameter defined in <JSP-Descriptor>. If it is false, the default character set in JVM is used for encoding.

4. webLogic Server needs to convert the data in HTTP Request (get and post) from its original encoding to Unicode for Java Servlet API processing, webLogic Server needs to know the data encoding method in hppt request. This can be set in <context-param> of weblogic. xml.
<Input-charset>
<Resource-path>/</resource-path>
<Java-charset-Name> GBK </Java-charset-Name>
</Input-charset>

5. when the Chinese characters retrieved from the Oracle database are incorrectly displayed, if the database uses the Chinese Character Set and type 2 JDBC driver, you can add weblogic. codeset = GBK attribute to solve this problem. The Code is as follows:
Java. util. properties props = new java. util. properties ();
Props. Put ("weblogic. codeset", "GBK ");
Props. Put ("user", "Scott ");
Props. Put ("password", "Tiger ");
String connecturl = "JDBC: WebLogic: Oracle ";
Driver mydriver = (driver)
Class. forname ("weblogic. JDBC. OCI. Driver"). newinstance ();
Connection conn =
Mydriver. Connect (connecturl, props );

6. If WTC is used to call the services in tuxedo and the Chinese characters cannot be correctly displayed on the JSP page, the nls_lang environment variable on the server where tuxedo is installed must be set the same as the character set in the database. For example, if the character set in the background Oracle database is set to simplified chinese_china.zhs16gbk, The nls_lang environment variable on the tuxedo application server should be set to: Export nls_lang = "simplified chinese_china.zhs16gbk"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.