Error-page directive in web.xml doesn't render UTF8 correctly

I have a web.xml application 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) renders correctly if rendered directly or even through a servlet filter.

I tried adding a filter:

request.setCharacterEncoding("UTF8");

      

But that doesn't help. Any ideas?

+1


source to share


3 answers


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

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



Everything seems to be great!

0


source


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



0


source


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

You should check this:

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

0


source







All Articles