I18n With JSTL
I18n With JSTL
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.fallbackLocale</param-name>
<param-value>en_US</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.locale</param-name>
<param-value>en_US</param-value>
</context-param>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/tld/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
</taglib>
5. Create your resource bundle (i.e. ApplicationResources_en_US.properties) and place it into WEB-
INF/classes/
msg.1=this is msg 1
msg.2=msg 2
6. Basically your webapps is now ready for i18n. below is an example of the JSP (i18n.jsp):
<%@ 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>Test i18n capable tag of JSTL</title></head>
<body>
<p>msg.1 = <fmt:message key="msg.1"/></p>
<p>msg.2 = <fmt:message key="msg.2"/></p>
<p><a href="?lang=en_US">English</a></p>
<p><a href="?lang=fr">French</a></p>
</body>
</html>