%@ page import="javax.servlet.jsp.jstl.core.Config, java.util.*" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
The following bundles exist in the web application: 'Resources', 'Resources_de', 'Resources_fr', 'Resources_it'. 'Resources' is the 'base' bundle and contains all messages in English. The italian bundle only holds one message (key=greetingMorning).
Set application-based locale: | French German Italian Spanish (no bundle) None |
Set fallback locale: | French German Italian Spanish (no bundle) None |
Request parameter "locale":
(This value is used to set the application based locale for this example)
Application based locale: <%=Config.find(pageContext, Config.FMT_LOCALE)%>
(javax.servlet.jsp.jstl.fmt.locale configuration setting)
Browser-Based locales:
<%
Enumeration enum = request.getLocales();
while (enum.hasMoreElements()) {
Locale locale = (Locale)enum.nextElement();
out.print(locale);
out.print(" ");
}
%>
(ServletRequest.getLocales() on the incoming request)
Fallback locale: <%=Config.find(pageContext, Config.FMT_FALLBACK_LOCALE)%>
(javax.servlet.jsp.jstl.fmt.fallbackLocale configuration setting)
KEY
VALUE
greetingMorning
greetingEvening
currentTime
serverInfo
undefinedKey