<fmt:setBundle> Tag
The <fmt:setBundle>
tag is used to load a resource bundle and store it in a named variable in the scope or in the bundle configuration variable.
Syntax
<fmt:setBundle baseName="<string>" var="<string>" scope="<string>"/>
Attributes
The <fmt:setBundle>
tag has the following attributes:
Attribute | Description | Required | Default Value |
---|---|---|---|
basename | The base name of the resource bundle family, exposed to the scope variable or configuration variable | Yes | None |
var | The variable to store the new resource bundle | No | Replace default |
scope | The scope of the variable | No | Page |
Example Demonstration
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
<title>JSTL fmt:setBundle Tag</title>
</head>
<body>
<fmt:setLocale value="en"/>
<fmt:setBundle basename="com.tutorialpro.Example" var="lang"/>
<fmt:message key="count.one" bundle="${lang}"/><br/>
<fmt:message key="count.two" bundle="${lang}"/><br/>
<fmt:message key="count.three" bundle="${lang}"/><br/>
</body>
</html>
The output is as follows:
One
Two
Three