Bug 19966

Summary: Changing locale during a session
Product: Taglibs Reporter: Ajay Soni <ajay.soni>
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 1.0   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Ajay Soni 2003-05-15 18:34:04 UTC
The thing I do not get to work is to change locale during a session. Once the 
locale is set, it is set as if it was in application scope.

I want users to be able to change language at any point of time during a 
session.
%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="WEB-INF/tags/c.tld" %>
<%@ taglib prefix="fmt" uri="WEB-INF/tags/fmt.tld" %>

<%-- 
  Set the locale to the selected one, if any. Otherwise, let the
  <fmt:setBundle> action pick the best one based on the Accept-Language
  header.
--%>

<%-- Interpret user's locale choice --%>
<c:if test="${param['locale'] != null}"%>
<% System.out.println("here"+request.getParameter("locale"));%>
  <fmt:setLocale value="${param['locale']}" scope="session" /%>
</c:if%>

<%-- Offer locale choice to user --%>
<a href="international.jsp?locale=en-US">USA</a> -
<a href="international.jsp?locale=de-DE">Deutschland</a> -
<a href="international.jsp?locale=fr-FR">French;</a>
<%-- Use URL rewriting to ensure proper session tracking --%>
<form method="get" action="<c:url value='/international.jsp' />">
  <input type=submit value="Stay in session">
</form>

<fmt:bundle basename="LabelsBundle" >



<html>
  <head>
    <title>
      <fmt:message key="s0" />
    </title>
  </head>
  <body bgcolor="white">
    <h1>
      <fmt:message key="s0" />
    </h1>
</html>
</body>
</fmt:bundle>
Comment 1 Pierre Delisle 2003-06-20 00:08:06 UTC
Fixed in JSTL 1.0.3.