How to test Tomcat’s character encoding configuration
I’ve seen many cases with displaying non-latin characters in Web Intelligence or other reporting tools.
It’s not always so easy to identify where is the issue coming from, so I’d like to help you with an easy testing method.
Prerequisites for this test is to make sure that the your database is configured to UTF-8 and you can also display non-latin characters using other tools.
- Please make sure that URIEncoding is set to UTF8
in Tomcat’s server.xml file.
You can validate this by following the steps written in KBA 1497582.
- Open Notepad++ and insert the following code
which gives back the content of a form using the GET method:
<%@ page contentType=“text/html; charset=UTF-8”%>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<title>Character encoding test page</title>
<p>Data posted to this form was:
<form method=“GET” action=“test1.jsp”>
<input type=“text” name=“mydata”>
<input type=“submit” value=“Submit”/>
<input type=“reset” value=“Reset”/>
- Save the file as “test1.jsp”
- Navigate to Tomcat’s ROOT directory
- Copy “test1.jsp” into this folder
- Open “test1.jsp” using IE. In my example the URL is: http://localhost:8080/test1.jsp
- Type in some non-latin characters, e.g. Chinese letters (形声字 / 形聲字)
- After clicking on the Submit button, you should get back the results.
Note: In the current example Tomcat’s UTF-8 configuration seems to be correct.
- If you remove URIEncoding=”UTF-8″ parameter from server.xml you should get something like this:
- Another possible output of a wrong configuration:
Please note that this is not a fail-safe method to make sure that the configuration is correct/incorrect, but it might help you to narrow down the issue.
I hope it will be useful for you.
Very much helpful , Bence 😀