12.07.2015 Views

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

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.

CHAPTER 11 ■ PAGES AND COMPONENTSTo use the core tag library, the page needs to import its URI <strong>with</strong> a prefix (i.e., XML namespace),assign the value 20 to the upperLimit variable <strong>with</strong> the tag, and then iterate from the number 3 tonumber 15. You can see the usage of the EL <strong>with</strong> the arithmetic expression ${upperLimit - 5}. Inside theloop, the value of the index (variable i) is tested to see whether its value is odd or even (). The tag displays the value of the index <strong>with</strong> the text ("${i} is even").The logic is only done via tags, and this page is totally XML compliant, using a markup languageeasy for non-<strong>Java</strong> programmers to read and understand.Formatting ActionsFormatting actions provide support for formatting dates, numbers, currencies, and percentages, andalso support internationalization (i18n). You can get or set locales and time zones, or get the encoding ofthe web page. Table 11-4 shows the actions contained in the format library.Table 11-4. Formatting ActionsActionDescriptionInternationalizes a JSP by pulling a message from a message bundle.Supplies a parameter for .Determines the resource bundle.Sets the locale.Sets the request’s character encoding.Specifies the time zone in which time information is to be formatted.Stores the specified time zone on a variable.Formats a numeric value (number, currency, percentage) in a localesensitivemanner.Parses the string representation of numbers, currencies, and percentages.Formats dates and times in a locale-sensitive manner.Parses the string representation of dates and times.316

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

Saved successfully!

Ooh no, something went wrong!