9 Replies Latest reply on Nov 30, 2008 4:51 AM by iisrail

    encoding utf-8

      Hi all,

      I have problem with saving and demonstartion of non ascii characters. From my point of view I do all the right things
      1) Defined Content-Type to utf-8
      2) Defined pageEncoding to utf-8
      3) In addition I've added filter to change pageEncoding to UTF-8

      but when for exampe I insert one hebrew character ,I've got in database other character , or if I insert russian characters '�¼�¾Ñ��º�²�°' - moskva in dabase I've got '<>A:20'
      that is my code:
      jsp page:

      <%@taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
      <%@taglib uri="http://richfaces.org/rich" prefix="rich"%>
      <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      
       <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
      
      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      <html>
      <head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       <link rel="stylesheet" type="text/css" href="stylesheet.css" />
       <title>Edit Node</title>
      </head>
      
      <body topmargin=20 leftmargin=20 >
      <f:view>
       <h:form id="form1" >
      
      
       <table cellpadding=4 border=0 cellspacing=0 background="Images/bg_pattern.png" width=100%>
       <tr>
       <td colspan="3" style="height:15px;"></td>
       </tr>
       <tr>
       <td style="width:20px;"> </td>
       <td class="Label">Display Text:</td>
       <td><h:inputText maxlength="40" size="10" value="#{editNode.displayText}"/></td>
       </tr>
       <tr>
       <td>
      
       <a4j:commandButton id ="btnUpdate" value="Update" action="#{editNode.update}"/>
       </td>
       </tr>
       </table>
      
       </h:form>
      </f:view>
      </body>
      
      </html>
      
      


      Managed bean:
      import com.igl.server.CMSPackage;
      
      public class EditNodeBean {
      
       private String displayText;
       private CMSPackage daoPack ;
      
       public EditNodeBean(){
       daoPack = ServiceLocatorSingle.getInstance().getCmsPackage();
       displayText = daoPack.getChar();
       System.out.println("construcor " +displayText );
       }
      
       public String getDisplayText() {
       System.out.println("getDisplayText " +displayText );
       return displayText;
       }
      
       public void setDisplayText(String displayText) {
       System.out.println("setDisplayText " +displayText );
       this.displayText = displayText;
       }
      
       public String update(){
       System.out.println("update " +displayText );
       daoPack.updateChar(displayText);
       return null;
       }
      
      }
      


      web.xml:
      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
       id="WebApp_ID" version="2.5">
       <display-name>charenc</display-name>
      
       <context-param>
       <param-name>org.richfaces.SKIN</param-name>
       <param-value>blueSky</param-value>
       </context-param>
       <context-param>
       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
       <param-value>server</param-value>
       </context-param>
      
      
      
      
      <filter>
       <filter-name>CharsetFilter</filter-name>
       <filter-class>CharsetFilter</filter-class>
      </filter>
      
      <filter-mapping>
       <filter-name>CharsetFilter</filter-name>
       <url-pattern>/*</url-pattern>
      </filter-mapping>
      
      
      
       <filter>
       <display-name>RichFaces Filter</display-name>
       <filter-name>richfaces</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
       </filter>
      
       <filter-mapping>
       <filter-name>richfaces</filter-name>
       <servlet-name>Faces Servlet</servlet-name>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
       </filter-mapping>
      
      
      
      
       <servlet>
       <servlet-name>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>/faces/*</url-pattern>
       </servlet-mapping>
      
      
       <welcome-file-list>
       <welcome-file>index.html</welcome-file>
       <welcome-file>index.htm</welcome-file>
       <welcome-file>index.jsp</welcome-file>
       <welcome-file>default.html</welcome-file>
       <welcome-file>default.htm</welcome-file>
       <welcome-file>default.jsp</welcome-file>
       </welcome-file-list>
      </web-app>
      


      Please help.
      Please inform me if my question was clear