5 Replies Latest reply on Jun 14, 2004 2:44 AM by dargrim

    JBoss and UTF Character encoding

    dargrim

      Hi,

      First, sorry for my english. It is not very good.

      I build simple application who send string with Polish characters from HTML to another jsp page and display it.
      I use "get" method to send this string.
      and I recive what's like that "ąęśćżółń"

      Bellow i put code of my simple application.

      index.jsp
      ---------------------------------------------------------------------------
      <%@ page language="java" pageEncoding="UTF-8" %>
      <!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
      
      <html>
       <head>
       <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
       <title>Polish Character Encoding Test: &#261;&#263;&#281;&#322;&#324;ó&#347;&#378;&#380;</title>
       </head>
       <body>
       <form action="Main" method="get">
       Polish string <input name="test" type="text" size="20"> 
       <input type="submit" value="Send">
       </form>
       </body>
      </html>
      
      -------------------------------------------------------------------------------
      rec.jsp
      -------------------------------------------------------------------------------
      <%@ page language="java" pageEncoding="UTF-8" %>
      <!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
      
      <html>
       <head>
       <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
       <title>Polish Character Encding Test: &#260;&#262;&#280;&#321;&#323;Ó&#346;&#377;&#379;</title>
       </head>
       <body bgcolor="#FFFFFF">
      
       I recive from index.jsp folowing string: "<%= request.getParameter("test") %>"
      
       </body>
      </html>
      
      ----------------------------------------------------------------------------------
      Main.java
      ----------------------------------------------------------------------------------
      import java.io.*;
      import javax.servlet.*;
      import javax.servlet.http.*;
      
      public class Main extends HttpServlet {
      
       protected void doGet(
       HttpServletRequest request,
       HttpServletResponse response)
       throws ServletException, IOException {
      
       RequestDispatcher disp = request.getRequestDispatcher("rec.jsp");
       disp.forward(request,response);
      
       }
      
       protected void doPost(
       HttpServletRequest request,
       HttpServletResponse response)
       throws ServletException, IOException {
      
       doGet(request,response);
       }
      }
      
      


      All files are encoded in UTF-8.
      If I send string vi "post" method all characters are displayed ok.
      If I change "forward" method of RequestDispatcher to "include" method string is displayed ok but all polish characters on page are displayed perhaps in ISO-8859-1 encoding.

      I need your help. What I do wrong?

      Piotr Brandys-Buczek

      My e-mail: Piotr.Buczek@telekomunikacja.pl

        • 1. Re: JBoss and UTF Character encoding
          dargrim

          I am disappointed,

          Thank's all for help !!!

          This matter is out-of-date.

          • 2. Re: JBoss and UTF Character encoding
            carpy1970

            As this is a FREE forum, and all contributions are given to it FREEly, you have no right to EXPECT FREE help from anyone, and therefore no right to be disapointed (in my opinion)

            • 3. Re: JBoss and UTF Character encoding
              dargrim

              One more time sorry for my English and thank you for reply.

              I am not expect help (free or "not free") but only information that my problem is so simple, so stuipid or another so ...

              Next time if i want to need help i buy support

              Thanks,
              I want to finish this topic.

              P.S.
              I think that help is always free ( it require desire only) and "non free help" is the same as support

              • 4. Re: JBoss and UTF Character encoding
                bardevjen

                I'll try to help you out here....no need to be grumpy :-)

                Look at your server.xml under jboss/default/server/deploy/tomcatxxx.sar/

                Be sure to add the parameter URIEncoding and set it to UTF8.



                I hope this helps!

                Cheers,
                Bard

                • 5. Re: JBoss and UTF Character encoding
                  dargrim

                  Thank you

                  You had right. I use JBoss 3.2.4 with tomcat 5, and set up useBodyEncodingForURI as "true". I this moment all is ok.
                  All parameters from "get" method are displayed as polisch characters.

                  One more time, thank you.