10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Calls to setContentType set the character encoding only if the given content type string<br />

provides a value for the charset attribute. Calls to setLocale set the character encoding only if<br />

neither setCharacterEncoding nor setContentType has set the character encoding before. To<br />

control the response encoding from JSP pages, you can use the JSTL fmt.setLocale tag.<br />

To obtain the character encoding for a locale, the setLocale method checks the locale encoding<br />

mapping for the web application. For example, to map Japanese to the Japanese-specific<br />

encoding Shift_JIS, follow these steps:<br />

1. Select the WAR.<br />

2. Click the Advanced Settings button.<br />

3. In the Locale Character Encoding table, Click the Add button.<br />

4. Enter ja in the Extension column.<br />

5. Enter Shift_JIS in the Character Encoding column.<br />

If a mapping is not set for the web application, setLocale uses a Application Server mapping.<br />

<strong>The</strong> first application in Chapter 5, “<strong>Java</strong>Server Pages Technology,” allows a user to choose an<br />

English string representation of a locale from all the locales available to the <strong>Java</strong> 2 platform and<br />

then outputs a date localized for that locale. To ensure that the characters in the date can be<br />

rendered correctly for a wide variety of character sets, the JSP page that generates the date sets<br />

the response encoding to UTF-8 by using the following directive:<br />

<br />

Further Information about InternationalizingWeb Applications<br />

Further Information about InternationalizingWeb<br />

Applications<br />

For a detailed discussion on internationalizing web applications, see the <strong>Java</strong> BluePrints for the<br />

Enterprise at http://java.sun.com/blueprints/enterprise.<br />

Chapter 15 • Internationalizing and LocalizingWeb Applications 473

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!