title: jsf facelet persian character encoding error
body: <p>I develop a java application with jsf and eclispeLink with netbeans 7.3.1 but my character don't save correctly. I look at request variable and saw that my character are not correctly show in the request object.</p>
  
  <p>My Jsf sample :</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
        xmlns:h="http://xmlns.jcp.org/jsf/html"
        xmlns:f="http://xmlns.jcp.org/jsf/core"&gt;
  
      &lt;ui:composition template="/template.xhtml"&gt;
          &lt;ui:define name="title"&gt;
              &lt;h:outputText value="#{bundle.CreateTblAccessTitle}"&gt;&lt;/h:outputText&gt;
          &lt;/ui:define&gt;
          &lt;ui:define name="body"&gt;
              &lt;h:panelGroup id="messagePanel" layout="block"&gt;
                  &lt;h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/&gt;
              &lt;/h:panelGroup&gt;
              &lt;h:form&gt;
                  &lt;h:panelGrid columns="2"&gt;
                      &lt;h:outputLabel value="#{bundle.CreateTblAccessLabel_id}" for="id" /&gt;
                      &lt;h:inputText id="id" value="#{tblAccessController.selected.id}" title="#{bundle.CreateTblAccessTitle_id}" required="true" requiredMessage="#{bundle.CreateTblAccessRequiredMessage_id}"/&gt;
                      &lt;h:outputLabel value="#{bundle.CreateTblAccessLabel_userName}" for="userName" /&gt;
                      &lt;h:inputText id="userName" value="#{tblAccessController.selected.userName}" title="#{bundle.CreateTblAccessTitle_userName}" /&gt;
                      &lt;h:outputLabel value="#{bundle.CreateTblAccessLabel_userTypeId}" for="userTypeId" /&gt;
                      &lt;h:selectOneMenu id="userTypeId" value="#{tblAccessController.selected.userTypeId}" title="#{bundle.CreateTblAccessTitle_userTypeId}" &gt;
                          &lt;f:selectItems value="#{tblUserTypeController.itemsAvailableSelectOne}"/&gt;
                      &lt;/h:selectOneMenu&gt;
                      &lt;h:outputLabel value="#{bundle.CreateTblAccessLabel_formId}" for="formId" /&gt;
                      &lt;h:selectOneMenu id="formId" value="#{tblAccessController.selected.formId}" title="#{bundle.CreateTblAccessTitle_formId}" required="true" requiredMessage="#{bundle.CreateTblAccessRequiredMessage_formId}"&gt;
                          &lt;f:selectItems value="#{tblFormController.itemsAvailableSelectOne}"/&gt;
                      &lt;/h:selectOneMenu&gt;
                      &lt;h:outputLabel value="#{bundle.CreateTblAccessLabel_activitesId}" for="activitesId" /&gt;
                      &lt;h:selectOneMenu id="activitesId" value="#{tblAccessController.selected.activitesId}" title="#{bundle.CreateTblAccessTitle_activitesId}" required="true" requiredMessage="#{bundle.CreateTblAccessRequiredMessage_activitesId}"&gt;
                          &lt;f:selectItems value="#{tblAccessActivitiesController.itemsAvailableSelectOne}"/&gt;
                      &lt;/h:selectOneMenu&gt;
                  &lt;/h:panelGrid&gt;
                  &lt;br /&gt;
                  &lt;h:commandLink action="#{tblAccessController.create}" value="#{bundle.CreateTblAccessSaveLink}" /&gt;
                  &lt;br /&gt;
                  &lt;br /&gt;
                  &lt;h:commandLink action="#{tblAccessController.prepareList}" value="#{bundle.CreateTblAccessShowAllLink}" immediate="true"/&gt;
                  &lt;br /&gt;
                  &lt;br /&gt;
                  &lt;h:link outcome="/index" value="#{bundle.CreateTblAccessIndexLink}"/&gt;
              &lt;/h:form&gt;
          &lt;/ui:define&gt;
      &lt;/ui:composition&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>MY Filter to change encoding : </p>
  
  <pre><code>public class EncodingFilter implements Filter{
  
      private String encoding;
  
      @Override
      public void init(FilterConfig filterConfig) throws ServletException {
          encoding = filterConfig.getInitParameter("requestEncoding");
          if( encoding==null ) encoding="UTF-8";
      }
  
      @Override
      public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
          HttpServletRequest httpRequest = (HttpServletRequest) request;
          HttpServletResponse httpResponse = (HttpServletResponse) response;
          httpRequest.setCharacterEncoding(encoding);
          httpResponse.setCharacterEncoding(encoding);
          response.setContentType("text/html;charset=utf-8");
          chain.doFilter(httpRequest, httpResponse);
      }
  
      @Override
      public void destroy() {
          throw new UnsupportedOperationException("Not supported yet."); 
      }
  
  }
  </code></pre>
  
  <p>My Template.xhtml</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
        xmlns:h="http://xmlns.jcp.org/jsf/html"&gt;
      &lt;h:head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
          &lt;title&gt;&lt;ui:insert name="title"&gt;Default Title&lt;/ui:insert&gt;&lt;/title&gt;
          &lt;h:outputStylesheet name="css/jsfcrud.css"/&gt;
      &lt;/h:head&gt;
  
      &lt;h:body&gt;
          &lt;h1&gt;
              &lt;ui:insert name="title"&gt;Default Title&lt;/ui:insert&gt;
          &lt;/h1&gt;
          &lt;p&gt;
              &lt;ui:insert name="body"&gt;Default Body&lt;/ui:insert&gt;
          &lt;/p&gt;
      &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My web.xml</p>
  
  <pre><code>&lt;web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt;
          &lt;param-value&gt;Development&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/faces/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;session-config&gt;
          &lt;session-timeout&gt;
              30
          &lt;/session-timeout&gt;
      &lt;/session-config&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;faces/index.xhtml&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
      &lt;filter&gt;
          &lt;filter-name&gt;encodingFilter&lt;/filter-name&gt;
          &lt;filter-class&gt;business.EncodingFilter&lt;/filter-class&gt;
          &lt;init-param&gt;
                  &lt;param-name&gt;requestEncoding&lt;/param-name&gt;
                  &lt;param-value&gt;UTF-8&lt;/param-value&gt;
          &lt;/init-param&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;encodingFilter&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
      &lt;jsp-config&gt;
          &lt;jsp-property-group&gt;
              &lt;url-pattern&gt;*.xhtml&lt;/url-pattern&gt;
              &lt;page-encoding&gt;UTF-8&lt;/page-encoding&gt;
          &lt;/jsp-property-group&gt;
      &lt;/jsp-config&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>what is the problem? how could i solve it?</p>