encoding problem with Struts

Discussion in 'Java' started by Malcolm, Jul 25, 2003.

  1. Malcolm

    Malcolm Guest

    Hi, all.

    I was wondering if someone could tell me what i do wrong. I've got a
    web-application (i use Struts 1.1) and i need to print strings
    containing data in russian. This is the page-source, but it prints
    invalid data ('?' characters istead of russian symbols).

    <%@ page language="java" %>
    <%@ taglib uri="/tags/struts-html" prefix="html" %>
    <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
    <%@ taglib uri="/tags/struts-logic" prefix="logic" %>
    <html:html locale="true">
    <head>
    <html:base />
    <title><bean:message key="show.title" /></title>
    </head>
    <body>
    <h2><bean:message key="show.top" /></h2>
    <hr width="400" align="left" />
    <logic:iterate id="article" collection="<%= ((java.util.LinkedList)
    request.getAttribute("results")).iterator() %>">
    <p>
    <b>
    <bean:write name="article" property="headline" />
    </b>
    [<bean:write name="article" property="topic" />]<br />
    <i>
    <bean:write name="article" property="magazineName" />--
    <bean:write name="article" property="issue" />
    </i><br />
    <bean:write name="article" property="body" />
    </p>
    </logic:iterate>
    </body>
    </html:html>

    Such behaviour looks like printing unicode symbols in ISO-8859-1. How
    can I change the default charset of output. I didn't manage to do it by
    just putting the <meta> tag specifing charset of Cp1251. May be I can
    set the encoding of the page to UTF-8, for example. Is it possible by
    editing Struts config files?

    Thanks for any advice!

    Best regards, Yevgen Malafeyev AKA Malcolm.
     
    Malcolm, Jul 25, 2003
    #1
    1. Advertising

  2. Malcolm wrote:

    > I was wondering if someone could tell me what i do wrong. I've got a
    > web-application (i use Struts 1.1) and i need to print strings
    > containing data in russian. This is the page-source, but it prints
    > invalid data ('?' characters istead of russian symbols).
    >
    > <%@ page language="java" %>
    > <%@ taglib uri="/tags/struts-html" prefix="html" %>
    > <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
    > <%@ taglib uri="/tags/struts-logic" prefix="logic" %>


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

    [snip]

    That should be it.

    -Manish

    --
    Manish Jethani (manish.j at gmx.net)
    phone (work) +91-80-51073488
     
    Manish Jethani, Jul 25, 2003
    #2
    1. Advertising

  3. Malcolm

    Malcolm Guest

    Hi Manish,

    Manish Jethani ?????:
    >>I was wondering if someone could tell me what i do wrong. I've got a
    >>web-application (i use Struts 1.1) and i need to print strings
    >>containing data in russian. This is the page-source, but it prints
    >>invalid data ('?' characters istead of russian symbols).
    >><%@ page language="java" %>
    >><%@ taglib uri="/tags/struts-html" prefix="html" %>
    >><%@ taglib uri="/tags/struts-bean" prefix="bean" %>
    >><%@ taglib uri="/tags/struts-logic" prefix="logic" %>

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


    It changed the codepage of the output. But it seems the strings are
    printed not in the codepage set for the web-page but in system coding
    (koi8-r in my case). Is it possible to force tomcat (or Struts) to print
    the String using codepage of the corresponding web-page or other
    codepage. For example I tried to print str.getBytes("Cp1251"), but it
    printed junk.

    Thanks for your answer.

    Best regards, Yevgen Malafeyev AKA Malcolm.
     
    Malcolm, Jul 26, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hardy Wang

    Encoding.Default and Encoding.UTF8

    Hardy Wang, Jun 8, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    18,867
    Jon Skeet [C# MVP]
    Jun 9, 2004
  2. Malcolm

    parameters encoding & struts

    Malcolm, Jul 30, 2003, in forum: Java
    Replies:
    1
    Views:
    3,648
    Malcolm
    Jul 31, 2003
  3. Aleksandar Matijaca
    Replies:
    2
    Views:
    8,323
    Aleksandar Matijaca
    Sep 19, 2004
  4. Replies:
    1
    Views:
    23,369
    Real Gagnon
    Oct 8, 2004
  5. Replies:
    2
    Views:
    373
Loading...

Share This Page