1 Reply Latest reply on Mar 21, 2006 1:17 AM by Ravi Prakash Reddy Ummadi

    URGENT - request.setCharacterEncoding(

    Ravi Prakash Reddy Ummadi Newbie

      Hi,

      I use JBOSS-4.0.2.
      My application is struts based.

      When my action class receives form parameters, the request is not able to handle unicode characters.

      The unicode characters are getting displayed as some junk characters.
      I searched weba and everywhere it is written that "request.setCharacterEncoding("UTF-8")" should solve the problem. But strangely it's not working.

      I tried even with Tomcat5.0. Here is the JSP file I wrote to test unicode characters.

      JSP:

      
      <%@page contentType="text/html;charset=utf-8" pageEncoding="utf-8" import="java.io.*" %>
      <%
       String enc = request.getCharacterEncoding();
       if (enc == null)
       {
       request.setCharacterEncoding("UTF-8");
      
       }
      String characters = request.getParameter("str");
      out.println(characters);
      
      %>
      


      Even the above code is not able to handle unicode characters with tomcat 5.0.

      If I set URLENCODING attribute of CONNECTOR element in server.xml , then tomcat is able to handle encoding properly.

      But when I set URLENCODING attribute of JBOSS_TOMCAT's SERVER.XML, it is not able to handle unicode characters. I mean, when I pass unicode character from form, and if I read using "request.getParameter(
      "str") " it gives me junk characters in place of unicode character.

      Effectively, there is no way that I can get unicode characters from request in my JBOSS application.

      Please hlep me how I can solve this problem.,

      Ravi Prakash