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" %>


	
		fmt:setLocale JSTL formatting tag example
	
	
	      
		   


Message after changing the locale.




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


	
  
          test.jsp
  	


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.