1 Reply Latest reply: Oct 13, 2009 9:27 AM by 843810 RSS

    Charset

    843810
      Hello,

      Please, I am desperated because everything I do about it doesn´t work. Locally I get, but not on the web (linux/cpanel).

      What I would like is to set everything used on JSP to UTF-8.

      I tried server.xml:

      URIEncoding="utf-8"

      ... web.xml:

      <init-param>
      <param-name>javaEncoding</param-name>
      <param-value>UTF-8</param-value>
      </init-param>

      ...on java start up:

      -Dfile.encoding=UTF8

      ...inside the own jsp:

      <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
      <%
      request.setCharacterEncoding("UTF-8");
      %>

      ...but nothing works. The JSP insists in working on reading request.getParameter() just if was encoded with ISO-8859-1.

      Please, give me some light. Thanks.

      Thanks.

      Edited by: LinkWS on Sep 28, 2009 5:40 AM

      Edited by: LinkWS on Sep 28, 2009 5:41 AM
        • 1. Re: Charset
          843810
          Your JSP container is defaulting to ISO-8859 but your parameters are UTF-8 encoded.

          You can work around your container with this code:
          String value = new String(getParameter("param").getBytes("ISO-8859-1"), "UTF-8");

          If you are using Tomcat, add the Connector attribute in server.xml, URIEncoding="UTF-8", otherwise Tomcat will assume ISO-8859 encoding to your parameters.

          HTH,
          Eugenio