background image

Messaging Tags

<< Internationalization Tag Library | Formatting Tags >>
<< Internationalization Tag Library | Formatting Tags >>

Messaging Tags

TABLE 7­6
Internationalization Tags
Area
Function
Tags
Prefix
I18N
Setting Locale
setLocale
requestEncoding
fmt
Messaging
bundle
message
param
setBundle
Number and Date Formatting
formatNumber
formatDate
parseDate
parseNumber
setTimeZone
timeZone
JSTL I18N tags use a localization context to localize their data. A localization context contains a
locale and a resource bundle instance. To specify the localization context at deployment time,
you define the context parameter javax.servlet.jsp.jstl.fmt.localizationContext,
whose value can be a javax.servlet.jsp.jstl.fmt.LocalizationContext or a String. A
String
context parameter is interpreted as a resource bundle base name. For the Duke's
Bookstore application, the context parameter is the String messages.BookstoreMessages.
When a request is received, JSTL automatically sets the locale based on the value retrieved from
the request header and chooses the correct resource bundle using the base name specified in the
context parameter.
Setting the Locale
The setLocale tag is used to override the client-specified locale for a page. The
requestEncoding
tag is used to set the request's character encoding, in order to be able to
correctly decode request parameter values whose encoding is different from ISO-8859-1.
Messaging Tags
By default, the capability to sense the browser locale setting is enabled in JSTL. This means that
the client determines (through its browser setting) which locale to use, and allows page authors
to cater to the language preferences of their clients.
Internationalization Tag Library
The Java EE 5 Tutorial · September 2007
216