1 Reply Latest reply on Feb 10, 2005 1:21 PM by jjm

    JBoss/Tomcat not properly reading UTF8 HTTP (POST) parameter

    jjm Newbie

      This was posted to the HTTPD forum, sorry for cross posting...


      Hello All,

      Hopefully this hasn't been addressed already, I did a quick search and wasn't seeing anything addressing this specifically.

      We're using JBoss fronted by Apache HTTPD 2.0.52. Found a strange bug. When a HTTP parameter (in this case, it is a submit button) is being posted with a non-ascii character (0xF3, lowercase o with acute). This is actually being posted as UTF8 (0xc3b3), and either JBoss or more likely Tomcat is
      not converting these two bytes to a single character (\u00f3). I want the value to be sent in UTF8, so this is correct. The problem is that somewhere along the line the data is not being interpreted as UTF8 and being read as two characters.

      If I use a GET, it will still fail. However, if I remove Apache from the picture, and use the URIEncoding attribute as follows:

      <Connector port="80" address="${jboss.bind.address}"
       maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
       enableLookups="false" redirectPort="8443" acceptCount="100"
       connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="UTF-8"/>

      It will work with a GET. Still will not work with POST. I switched back to using Apache, and changed the AJP connector to also use the URIEncoding attribute. This fixed the GET, but POST is still not working properly.

      Other than changing our forms to use a GET, does anyone know of a solution?

      We're using JBoss 4.0.0, Httpd 2.0.52, and mod_jk2 (not sure of exact version).

      Any suggestions?


        • 1. Re: JBoss/Tomcat not properly reading UTF8 HTTP (POST) param
          jjm Newbie

          To anyone reading this with a similar problem, I ended up fixing the problem by using a filter to call setCharacterEncoding("UTF8") on the request and response objects.

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