You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Hi...@softwareag.com on 2004/10/05 16:31:14 UTC

Internationalizing a Struts project

Hi there.

I'm working on i18n of a Struts based project. All references I find about this topic deal with using messages depending on the user's locale. Has anyone ever experienced problems with national special characters (such as currency symbols for sterling or euro?

Hiran


-----------------------------------------
Hiran Chaudhuri
SAG Systemhaus GmbH
Elsenheimer Straße 11
80867 München
Phone +49-89-54 74 21 34
Fax   +49-89-54 74 21 99



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Internationalizing a Struts project

Posted by Craig McClanahan <cr...@gmail.com>.
On Tue, 5 Oct 2004 16:31:14 +0200, hiran.chaudhuri@softwareag.com
<hi...@softwareag.com> wrote:
> Hi there.
> 
> I'm working on i18n of a Struts based project. All references I find about this topic deal with using messages depending on the user's locale. Has anyone ever experienced problems with national special characters (such as currency symbols for sterling or euro?
> 
> Hiran
> 

This issue is more related to the way JSP works than Struts, but
here's a summary.

The most important consideration for national characters is the
character encoding that will be used to send the response back to the
browser.  Unless you ask for something different explicitly, JSP pages
are always sent back in ISO-8859-1 (basically 7-bit ASCII), which will
create problems with characters outside the 7-bit range.

To ask for the content encoding to be set differently, you use the
page directive at the top of your JSP pages, for example, to select
UTF-8:

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

If all of your national characters are produced by custom tags (such
as <bean:write> or <html:input> in the case of Struts), this should be
all you need.  If you also want to use literal characters in the
template text of your JSP page, you have to go one step further --
actually store the source code of your JSP page in an appropriate
encoding, and tell the JSP compiler what that encoding is.  The
details of how you save pages in a particular encoding will depend on
the text editor or IDE you are using, but the mechanism to tell JSP
about it is standard.  So, if you also use UTF-8 encoding for your
source page, you'd say:

  <%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" T%>

Craig McClanahan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org