JBoss, Struts and UTF-8

Discussion in 'Java' started by Electric Natcho, Nov 29, 2003.

  1. Hi, I'm working on an internationalized application using JBoss 3.2
    (with Tomcat 4.1), IIS and Struts 1.1. We want to return utf-8 encoded
    pages to ensure our responses can support many languages. It is my
    understanding that we should be able to tell Java how to encode our
    responses and it will handle all of the encoding for us (so we don't
    have to worry about individually encoding every resource, jsp,
    includes etc).

    To set the encoding to utf-8, I've done the following:
    1) assigned the encoding within the controller options in
    struts-config:
    <controller contentType="text/html;charset=UTF-8"
    nocache="true"
    processorClass="org.apache.struts.action.RequestProcessor" />
    2) included a jsp page directive
    <%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8"
    %>
    3) included a meta tag within the html page itself
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    This won't encode the response but it should help the browser detect
    the encoding.

    I'm aware that the encoding can only be set in the response before
    writing to the underlying Writer (since it would not be smart to
    change the encoding during a response).

    What's the best way to ensure the encoding is working properly? I've
    viewed my pages using Opera (7.23) and it says the encoding is
    ISO-8859-1 while it detects utf-8 for other websites (such as google).
    Internet Explorer doesn't really tell me anthing.

    Thanks in advance.
     
    Electric Natcho, Nov 29, 2003
    #1
    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. han
    Replies:
    0
    Views:
    499
  2. Jubz
    Replies:
    0
    Views:
    2,355
  3. LprzemekL
    Replies:
    0
    Views:
    554
    LprzemekL
    Apr 10, 2008
  4. jmfauth
    Replies:
    4
    Views:
    340
    jmfauth
    Oct 13, 2010
  5. Grzegorz ¦liwiñski
    Replies:
    2
    Views:
    1,007
    Grzegorz ¦liwiñski
    Jan 19, 2011
Loading...

Share This Page