CodesJava

Easy learning with example program codes

JSTL fmt:setLocale Formatting Tag


The JSTL <fmt:setLocale> Formatting Tag is used for setting the locale configuration variable with the given locale.

Syntax: <fmt:setLocale value=”localeValue” />

fmt:setLocale tag attributes:

Attribute Description Required
value It specify a two-part code that represents the ISO-639 language code and an ISO-3166 country code. Yes
variant It specify the browser specific variant. No
scope It specify the scope of the locale configuration variable. No

Example:

test.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
 
<html>
	<head>
		<title>fmt:setLocale JSTL formatting tag example</title>
	</head>
	<body>
	      <fmt:bundle basename="com.javawithease.properties.message">
		   <fmt:message key="message.first"/><br/>
		   <fmt:message key="message.second"/><br/>
		   <fmt:message key="message.third"/><br/>
	      </fmt:bundle>
 
	      <h4>Message after changing the locale.</h4>
	      <fmt:setLocale value="en"/>
	      <fmt:bundle basename="com.javawithease.properties.message">
		   <fmt:message key="message.first"/><br/>
		   <fmt:message key="message.second"/><br/>
		   <fmt:message key="message.third"/><br/>
	      </fmt:bundle>
	</body>
</html>

message_en_US.properties

message.first = This is first message using en_US locale.
message.second = This is second message en_US locale.
message.third = This is third message en_US locale.

message_en.properties

message.first = This is first message using en locale.
message.second = This is second message using en locale.
message.third = This is third message using en locale.

web.xml

<web-app>
 
  <welcome-file-list>
          <welcome-file>test.jsp</welcome-file>
  </welcome-file-list>	
 
</web-app>

Output:

jsp example 48
 
Download this example.
 
Next Topic: JSTL fmt:timeZone Formatting Tag with example.
Previous Topic: JSTL fmt:setBundle Formatting Tag with example.

Related Topics:

JSTL fmt:formatNumber Formatting Tag with example.
JSTL fmt:parseNumber Formatting Tag with example.
JSTL fmt:formatDate Formatting Tag with example.
JSTL fmt:parseDate Formatting Tag with example.
JSTL fmt:bundle Formatting Tag with example.
JSTL fmt:setBundle Formatting Tag with example.
JSTL fmt:setLocale Formatting Tag with example.
JSTL fmt:timeZone Formatting Tag with example.
JSTL fmt:setTimeZone Formatting Tag with example.
JSTL fmt:requestEncoding Formatting Tag with example.

 

Sign Up/ Sign In
Ask a Question


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki