|
|
Internationalization Tag Library in JSP
|
Tutorials

Jsp

|
Topic |
What is Internationalization Tag Library in JSP?
|
|
Explanation |
|
Internationalization Tag Library or 118N Tag library lists the tags that confirm the client locale settings
for formatting and parsing client sensitive data like currency, date, etc in a locallized or customized manner.
The following table lists all the tags that confirm to 118N standards and is used with a prefix "fmt".
Syntax:
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
| Function |
|
| Setting Locale |
| setLocale, | SetLocale tag is used set the linguistic conventions of a particular region |
requestEncoding
| requestEncoding tag is used to set character encoding. |
|
| Messaging |
| bundle, | bundle tag is used to set the resource bundle for a given tag body, |
| message, | Message tag allows you to retrieve text messages from a locale-specific resource bundle and
display it on a JSP page. |
| setBundle | setBundle is to set the localization context in a variable . |
|
| Number andDate Formatting |
| formatNumber, | formatNumber is used to convert a number using the java class instance |
| formatDate | formatDate is used to convert a number using the java class instance |
setTimeZone, parseDate, parseNumber | All these tags needs to specify the date, number explicitly to convert into an object. |
|
Example:
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"
prefix="fmt" %>
<p>Convert the number 14.3 with 4 decimal places</p>
Formatting: <fmt:formatNumber value="123.4" type="NUMBER"
minFractionDigits="4" />
Result:
Convert the number 14.3 to have 4 decimal places
Formatting: 123.4000
In the above example we have used the 118N tag to add "4" decimal places to the number given.
Example:
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<jsp:useBean id="dat" class="java.util.Date" />
<fmt:formatDate value="${dat}" type="time" />
Result:
1:44:40 PM
In the above we have used the "<:jsp:useBean/>" tag to include the java date class, using the format
tag attribute "type" the time alone is displayed.
|
|
A Note |
|
JSP(Java Server Pages) is one of the most used Server Side Programming Language in the world. Simple introduction, basic program codes with examples. Begin coding your own JSP scripts with this online tutorial. Hope you enjoy this tutorial. Do send your feedback or suggestions on this JavaServer Pages tutorial. This is a copyright content.
|
|
|
|