Menu

form "ISO-8859-1" charset to the ""Cp1251"

Help
2003-07-15
2003-08-07
  • Serge Dolgopolov

    I'm trying to use DbForms under Tomcat4.0.6.
    I use this directive in my jsp pages
    <%@ page contentType="text/html; charset=windows-1251" %>.
    But when I post data to the DB I've got values ?????? for my fields.
    Where I should do conversion form "ISO-8859-1" charset to the ""Cp1251".

     
    • Henner Kollmann

      Henner Kollmann - 2003-08-06

      Which database are you using? Could you set up your database to use CP1251?

      Henner

       
      • Serge Dolgopolov

        I use Oracle 8.1.7 for Windows.
        The database created with codepage Cp1251.
        I use any client and get a correct result.
        I used this Db for the Java project under JServ and everything works fine.
        But under Tomcat and Dbforms I've got a trouble.
        As I know there are 2 major approach for solving encoding  problem.
        1. Put in your control servlet code like this
        public void doPost(HttpServletRequest request,HttpServletResponse response)
          throws ServletException, IOException
        {
        // In the real world we have read charset value from servlet config

        request.setCharacterEncoding("Cp1251");

        String value = request.getParameter("value");
        ...
        }
        2. Use a filter.
           2.1 I've added to the top of the web.xml
             <filter>
                 <filter-name>Set Character Encoding</filter-name>
                 <filter-class>filters.SetCharacterEncodingFilter</filter-class>
                 <init-param>
                     <param-name>encoding</param-name>
                     <param-value>UTF-8</param-value>
                 </init-param>
           </filter>
            <filter-mapping>
                 <filter-name>Set Character Encoding</filter-name>
                 <url-pattern>/*</url-pattern>
             </filter-mapping>
           2.2 Then I've added to the ..\WEB-INF\classes\filters
               a filter class.
           2.3 Unfortunately when I've restarted my Tomcat the application
           doesn't work. I got a error about parsing web.xml.
           2.4 For my simple test servlet this way works fine.
           I prefer the second way but this approach doesn't work in my
           example.
           Why ?

         
        • Henner Kollmann

          Henner Kollmann - 2003-08-07

          I do not know why you get the parsing error. Never worked with filter before.

          Maybe you could share the filter code so that we can build it into dbforms?
          And test the web.xml?

          regards,
          Henner

           

Log in to post a comment.

MongoDB Logo MongoDB