UTF-8 Encoding problem in JSPs (Tomcat 5.5.15)


Web tier: servlets, JSP, Web frameworks: UTF-8 Encoding problem in JSPs (Tomcat 5.5.15)

  1. I know there have already been some posts in the past about this. But no matter what I tried, I can't seem to get Tomcat to work properly when it comes to displaying UTF-8 encoded content in the jsps.

    Basically I'm simply trying to display non-ascii (an non ISO-8859-1) characters in my jsp pages.

    For tomcat configuration, I have provided both the -Dfile.encoding=UTF-8 in catalina.sh and URIEncoding=UTF-8 in server.xml.

    I placed the following as the first line of each jsp:
    <%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

    and this meta as the first item under <head>:
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

    I also have a filter setup which sets the character encoding
    of each request to UTF-8.

    But still it does not work!

    When I create a simple html file with the special characters in it (therefore no jsp processing), they display properly.

    I would really appreciate your help on this.


    Threaded Messages (2)

  2. Solved[ Go to top ]

    The solution is posted
  3. Solution[ Go to top ]

    Try to add this line at the top of your .jsp file:


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