Set request character encoding of JSF input submitted values to UTF-8

Related searches

I have the same problem as Set request character encoding of JSF input submitted values to UTF-8 in GlassFish, the submitted values arrive as Mojibake. However, the answer is targeted at GlassFish and I'm using JBoss AS 7.

I've already specified the JDBC connection URL to use UTF-8:


And in top of my JSF page:

<?xml version='1.0' encoding='UTF-8' ?>

How can I solve the same problem in JBoss AS 7? Or better, in a more generic way so that it works in all servers?

The question which you linked to has already excluded the DB encoding from being the cause because the problem already occurs during printing/redisplaying the submitted value before saving in DB. Thus, the problem is in HTTP request encoding.

Your JDBC connection URL with the charset specified,


only tells the MySQL JDBC driver to use UTF-8 to decode values in SQL queries before sending it to DB. This is not only completely beyond JSF's scope, but this is also not the cause of your problem, provided that you're absolutely positive that you've the same problem as in the linked question.

Your XML prolog with the charset specified,

<?xml version='1.0' encoding='UTF-8' ?>

only tells the XML parser to use UTF-8 to decode the XML source before building the XML tree around it. The XML parser actually being used is SAX as internally used by Facelets during JSF view build time. This part has completely nothing to do with HTTP request/response encoding and is thus very unlikely the cause of your problem.

None of them sets the HTTP request encoding, while you need to set the HTTP request encoding. The question which you linked to already shows how to do that for the Glassfish server. In your case, you're however using JBoss AS server. The Glassfish-specific setting is then inapplicable and JBoss doesn't support anything like that. You'd need to bring in a custom servlet filter to do the job. E.g.

public class CharacterEncodingFilter implements Filter {

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
        chain.doFilter(request, response);

    // ...

Set request character encoding of JSF input submitted values to UTF-8, The question which you linked to has already excluded the DB encoding from being the cause because the problem already occurs during� The problem in not in the DB encoding since I already have the wrong value before inserting it in the DB. I'm using JSF 2 with Facelets and GlassFish as application server. jsf utf-8 character-encoding glassfish http-request-parameters

In standalone.xml, add atributte url-charset="UTF-8" in the tag http-listener name="default", and add atributte default-encoding="UTF-8" in the tag servlet-container.

Lessons Learned: Solving character encoding issues in JSF, Implement a servlet filter to do the UTF-8 encoding of the requests and @ exception IOException if an input/output error occurs * @exception select and set the character encoding to be used if (ignore || (request. getInitParameter(" encoding"); String value = filterConfig. This is an awesome post. The resulting value (if not null) is used to set the request character encoding. The JSF-RI 1.2 code is similar - calculateCharacterEncoding(FacesContext) in ViewHandler appears to parse the raw header, as opposed to using the CharacterEncoding getter on ServletRequest.

Adding this to JBOSS_HOME/standalone/configuration/standalone.xml solved it for me:

    <property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/>
    <property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/>

Got it from

HTML form accept-charset Attribute, <form action="/action_page.php" accept-charset="utf-8"> <label for="fname">First name:</label> <input type="submit" value="Submit"> </form>. Try it Yourself �� I also tested a servlet handling 'multipart/form-data' request using the character encoding set by 'ServletContext#setRequestCharacterEncoding'. The 'hello' request parameter's value , the file name and the file contents were encoded by UTF-8 at the request body, but 'hello' request parameter's value and the file name were not successfully decoded.

Unicode input retrieved via PrimeFaces input components become , When I was still using PrimeFaces v2.2.1, I was able to type unicode input such Normally, JSF/Facelets will set the request parameter character encoding to UTF- 8 by HttpServletRequest#setCharacterEncoding() only sets the encoding for POST Set request character encoding of JSF input submitted values to UTF-8� Value Description; character_set: A space-separated list of one or more character encodings that are to be used for the form submission. Common values: UTF-8 - Character encoding for Unicode; ISO-8859-1 - Character encoding for the Latin alphabet; In theory, any character encoding can be used, but no browser understands all of them.

CharacterEncodingFilter, This filter will set the request body character encoding when not already set by the character encoding to the server-default value, which is not UTF-8 per se. Please note that this only affects HTTP POST requests, not HTTP GET requests. Unicode input retrieved via PrimeFaces input components become corrupted� Content-Type: text/html; charset=utf-8. In theory, any character encoding that has been registered with IANA can be used, but there is no browser that understands all of them. The more widely a character encoding is used, the better the chance that a browser will understand it.

Hi, I had the same problem: no matter what tags I had on the JSP to specify UTF-8 as the encoding: multi byte characters would not be rendered correctly (using jDeveloper / OC4J). I finally discovered that when compiling the pages, jDeveloper was passing -encoding Cp1252 to the JDK, thus instructing it to treat my JSPs as Cp1252 encoded!

  • It is impossible to understand what your problem is. Please edit your question to be clear on the issue you faced.
  • My problem is the same as this link […. I'm using Jboss 7 AS instead of Glassfish. I want to ask how to fix the problem in Jboss.
  • When I am trying to use : jdbc:mysql://localhost:3306/mydb?useUnicode=yes&characterEncoding=UTF-8 in my application-context.xml, it gives me an error The reference to entity "characterEncoding" must end with the ';' delimiter, can u plz help me with the issue
  • Incredible. Here we are in 2014, using the latest OS, JEE, app server, database - all UTF-8. And still we need some workaround to have special characters handled correctly. Thanks for this solution!
  • None of the previous answers worked for me. Then I posted what helped me.