views:

913

answers:

3

I have an application web.xml with the following entry:

<error-page>
    <error-code>404</error-code>
    <location>/system_files/error/p_notfound.jsp</location>
</error-page>

However, when this page is displayed, Japanese characters are garbled.

The same page (p_notfound.jsp) displays properly if displayed directly or even through the servlet filter.

I tried adding a filter to:

request.setCharacterEncoding("UTF8");

But that doesn't help. Any ideas?

A: 

I have experienced this problem too. I resolved it by upgrading. Are you using the latest version of Tomcat?

Jonas Klemming
A: 

Using request.setCharacterEncoding() won't help you since it justs changes the encoding used to parse request parameters.

You should check this:

  • Is the JSP content really UTF-8 encoded?
  • Have you set an pageEncoding parameter for your JSP Page?

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

Eduard Wirch
A: 

I tried the suggestion above, but I actually fixed this by adding the response header to force it through the servlet filter:

response.setHeader("Content-Type", "text/html; charset=UTF-8");

Seems to work just fine!