Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Jsp JSP Locale

Related Tutorials


 
 

Share on Google+Share on Google+

JSP Locale

Advertisement
JSP Locale is used to get the preferred locale of the user. A user can configure their browser with a US language locale ("en_US") as the preferred one.

JSP Locale

        

JSP Locale is used to get the preferred locale of the user. A user can configure their browser with a US language locale ("en_US") as the preferred one. Apart from this user has configured their browser with various locales. It is designed in a way that returns a more readable name ("es_ES") for the locale.

Understand with Example

The Tutorial illustrate you how to get the locale from the jsp page. The locale.jsp include a page import directive that import a package "java.util.Locale". This Package define an object that represents a specific geographical, political, or cultural region. You can see in the given example that we have used the request.getLocale() method provided by the interface ServletRequest that will return the preferred locale based on the Accept-Language header.

request.getLocale ( ) :  The method is used to return the current locale based on the Accept-Language header.

Here is the code of locale.jsp

<%@ page import="java.util.Locale "%>
<html>
<body>
<%
Locale l = request.getLocale();
out.println("Locale is :"+l);
%>
</body>
</html>

Output will be displayed as:

Download Source Code:

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 4, 2009

Related Tutorials

Discuss: JSP Locale   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com