Home Jsp JSP Locale



JSP Locale
Posted on: February 4, 2009 at 12:00 AM
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:

Related Tags for JSP Locale:
cdesignjspbrowserlanguageiousersedgetlocalereadnamereturnthisconfiglocalrowjsforrowswithadatoconfigurewsesignedreflanwsesignitdescanvarusefromartbrowseinpartcalasmparcajadesagelocmerefersurnspatisirhapreeaarconfreadablertvavariousssrithabablaphatfeesiesipronomo


More Tutorials from this section

Ask Questions?    Discuss: JSP Locale   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.