Friday, January 13, 2012

How to display/Store Chinese Character Thru Browser

The following is extracted from http://java.sun.com/developer/technicalArticles/Intl/HTTPCharset/#browser

Server: Tomcat
1. Setting the context parameter is done in the WEB-INF/web.xml file.

<context-param>
<param-name>PARAMETER_ENCODING</param-name>
<param-value>UTF-8</param-value>
</context-param>

2. Add the following code to your JSP file.
<%
    //Must put in the first section of the jsp page
    String paramEncoding = application.getInitParameter("PARAMETER_ENCODING");
    request.setCharacterEncoding(paramEncoding); 

%>
*Please note that the following lines must be inserted at the begining of the JSP page after header declaration (eg. tagLib or Page), before any other content processing.

No comments:

Post a Comment