5 Replies Latest reply on Sep 21, 2005 5:08 AM by julien1

    UTF-8 form support not working Jboss portal?

    kevs3d

      To get the display of UTF-8 characters to work correctly, I added the following to all of our portlet JSP pages:

      <%@ page contentType="text/html;charset=UTF-8" %>

      We found that JBoss Portal will display UTF-8 characters fine - BUT we have not found a why to submit them correctly in a FORM yet... I am looking for a solution for that now. I have tried adding acceptCharset="UTF-8" to all HTML FORM tags but that hasn't worked. And I have also tried changing the line in the theme index.jsp:
      <meta http-equiv="Content-Type" content="text/html" />
      to
      <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />

      But that didn't work either :(

      However I say a forum post reply by Julian:
      http://www.jboss.org/index.html?module=bb&op=viewtopic&t=64828

      I have tried making these changes as suggested by Julian:

      org.jboss.portal.core.invocation.ContentTypeInterceptor
      line 113

       // Set content type
       response.setContentType(mimeType);
       response.setCharacterEncoding("UTF-8");
      



      So the pages are showing UTF-8 encoding in both IE and FireFox. This is fine and UTF-8 multi-byte characters are displaying ok.

      This image shows that working:
      http://www.kevs3d.co.uk/dev/jboss_utf8.png

      So now I attempt to enter UTF-8 characters in my FORM, the HTML FORM has the following attribute: acceptCharset="UTF-8" this image shows the input form:

      http://www.kevs3d.co.uk/dev/jboss_forminput.png

      As you can see it's working fine allowing you to input the characters.

      Now we submit the form. At this point if I check the value of the fields submitted to my bean in the debugger the values are a mess of characters and incorrect :( As can be seen on the next screen shot where we output the submitted characters back to the browser:

      http://www.kevs3d.co.uk/dev/jboss_formoutput.png

      Exactly the same web-application, running out of the Jboss Portal (still inside JBoss - but running as a TomCat web-app) works fine and the characters are submitted correctly back to the web-server.

      Does anyone have any idea what I need to do in JBoss Portal to fix this?

      Thanks,

      Kevin
      --
      http://www.alfresco.org


        • 1. Re: UTF-8 form support not working Jboss portal?
          martingi

          I am sending UTF-8 / German chars through a form and it works for me. However it was a longer way for me to get there:
          http://www.jbossgroup.com/index.html?module=bb&op=viewtopic&t=63925&view=previous

          The solution for me was not to modify anything in the portal, but to change ... "the default encoding of my linux system to UTF-8. So if I am doing a
          # echo $LANG
          I get
          DE_de.UTF-8 "

          • 2. Re: UTF-8 form support not working Jboss portal?
            fheldt

            You have to submit the form with the right charset

            <form method='post' accept-charset="UTF-8" ...>

            • 3. Re: UTF-8 form support not working Jboss portal?
              kevs3d

               

              "fheldt" wrote:
              You have to submit the form with the right charset

              <form method='post' accept-charset="UTF-8" ...>


              Yes I'm already doing that as I said in my previous message:
              >So now I attempt to enter UTF-8 characters in my FORM, the HTML FORM has the following attribute: acceptCharset="UTF-8"...

              The issue appears to in the portal, as the same webapp run plain in TomCat (and in Jboss) does not have these issues.

              Kev
              --
              http://www.alfresco.org

              • 4. Re: UTF-8 form support not working Jboss portal?
                kevs3d

                So any other interested parties know, I have fixed the issue. I modified the file:

                org.jboss.portal.server.servlet.AbstractMainServlet

                and changed this method thus:

                 protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
                 {
                 log.info("Setting character encoding to UTF-8...");
                 req.setCharacterEncoding("UTF-8");
                 PortalServer container = getContainer();
                 ServerManager manager = container.getManager();
                 InvocationFactory ctx = manager.getInvocationContext();
                 Invocation invocation = ctx.decode(req, resp);
                 invoke(invocation);
                 }
                


                This fixed the issue and Form characters are now correctly handled as UTF-8 in the portal pages.

                Thanks,

                Kevin
                --
                http://www.alfresco.org

                • 5. Re: UTF-8 form support not working Jboss portal?

                  Kev, can you add a jira task in the 2.0.1 project to remind us to add your change ?