Home Products QA Support Contact

Tomcat and UTF8

Tomcat jsp pages don't serve utf8 properly without the following tag:

<%@ page
contentType="text/html; charset=UTF-8"

Also, if you want to get utf8 urls to work, put the following property in your connectors in your server.xml file:


The other thing you may have to do is add a utf8 file encoding command line option to your java run command in your startup file, for instance startup.sh.


If you're going to store UTF-8 in session data, you need to set the request to UTF-8 encoding before referencing the session.

HttpSession session = request.getSession();

To properly use response.sendRedirect, you'll need to convert UTF-8 to a Latin equivalent. The following has worked here:

byte[] utfBytes = s.getBytes("UTF-8");
String s2 = new String(utfBytes, "ISO-8859-1");

This is as of version 5.5.15