The output is as follows: One Two ThreeUnoDosTres See [](#) and [](#) for more information. * * JSP Standard Tag Library](#)
Jstl Format Setlocale Tag
[JSP Standard Tag Library](#)
The tag is used to store a given locale in a locale configuration variable.
### Syntax
<fmt:setLocale value="" variant="" scope=""/>
### Attributes
The tag has the following attributes:
| **Attribute** | **Description** | **Required** | **Default Value** |
| --- | --- | --- | --- |
| value | Specifies the ISO-639 language code and ISO-3166 country code | Yes | en_US |
| variant | Specific browser variant | No | None |
| scope | Scope of the locale configuration variable | No | Page |
* * *
## Program Example
Resource bundles contain locale-specific objects. Resource bundles contain key-value pairs. When your program needs locale-specific resources, you can share all keys across all locales, but you can also specify translated values for a locale. Resource bundles help provide content assigned to a locale.
A Java resource bundle file contains a series of key-value pairs. The method we are concerned with involves creating compiled Java classes that inherit from the java.util.ListResourceBundle class. You must compile these classes and place them in the CLASSPATH of your web application.
Let's define a default resource bundle:
package com.tutorial;import java.util.ListResourceBundle;public class Example_En extends ListResourceBundle { public Object[][] getContents() { return contents; } static final Object[][] contents = { {"count.one", "One"}, {"count.two", "Two"}, {"count.three", "Three"}, };}
Now, define another resource bundle for the Spanish Locale:
package com.tutorial;import java.util.ListResourceBundle;public class Example_es_ES extends ListResourceBundle { public Object[][] getContents() { return contents; } static final Object[][] contents = { {"count.one", "Uno"}, {"count.two", "Dos"}, {"count.three", "Tres"}, };}
Compile the above files into Example.class and Example_es_ES.class, then place them in the CLASSPATH of your web application. Now you can use JSTL tags to display these three numbers, like this:
JSTL fmt:setLocale Tag
The output is as follows: One Two ThreeUnoDosTres See [](#) and [](#) for more information. * * JSP Standard Tag Library](#)
The output is as follows: One Two ThreeUnoDosTres See [](#) and [](#) for more information. * * JSP Standard Tag Library](#)
YouTip