Thursday, November 17, 2005

Tip - Internationalization using JSTL: locale

When a user sends a request to your server, the user's browser uses the URL information to create a request message. Amongst other information, the request message contains an Accept-Language header that provides information to the server about the preferred languages. This helps the server to localize the application. We can use JSP Standard Tag Library (JSTL) to find the locale (represents a particular geographical, political, or cultural region) of the user.

The Expression Language (EL) is geared towards looking up objects and their properties, and performing simple operations on them. pageContext is a JSTL implicit object, that has a property named request, which in turn has a property named locale. The follwing JSP page extracts the local information of the user.
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body bgcolor="white">
The Locale used by this PC is <c:out value="${pageContext.request.locale}" />;
</body>
</html>

Technorati Tags:
Blogs linking to this article

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home