Bug 16751 - fmt:setLocale value can't be changed
Summary: fmt:setLocale value can't be changed
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Standard Taglib (show other bugs)
Version: unspecified
Hardware: Other All
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2003-02-04 09:11 UTC by Pere Soler
Modified: 2004-11-16 19:05 UTC (History)
0 users

Example <fmt> usage that doesn't work fine. (461.07 KB, application/zip)
2003-02-05 10:10 UTC, Pere Soler

Note You need to log in before you can comment on or make changes to this bug.
Description Pere Soler 2003-02-04 09:11:56 UTC
The fmt:setLocale value doesn't change for the scope. The value can only be
fixed the first time, but subsequent invocations changing the value doesn't work
If we have one Jsp that is used to fix the language of an aplication, if the
language is changed using fmt:setLocale whit scope="sessio", the other JSP don't
catch this change when they use fmt:message.
I'm using jboss-3.0.3_tomcat-4.1.12 ang I have changed the conf/web.xml
enablePooling to false.
Is the same problem that is described in
Comment 1 Pere Soler 2003-02-05 10:10:55 UTC
Created attachment 4738 [details]
Example <fmt> usage that doesn't work fine.
Comment 2 Pere Soler 2003-02-05 10:19:37 UTC
The attachment is a war file that contains an example of <fmt> usage that
doesn't work fine. I attached with the name fmtexample.war. It can be deployed
simply copying the war file to the deploy directory. 
Comment 3 Pierre Delisle 2003-02-05 18:09:21 UTC
The sample code provided fails to give the proper locale because
<fmt:setLocale> is used erroneously.

The code in manager.jsp has the following:

   <fmt:setLocale value="<%=lang%>" scope="session"/>

This should throw an exception at translation time because attributes
in EL tag libraries have <rtexprvalue> set to false.
The string literal "<%=lang%>" is passed as is to the tag handler.

You can fix your sample code in the following ways and it will then
work fine.

Use the RT tag library:
   <%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt_rt" %>
   <fmt_rt:setLocale value="<%=lang%>" scope="session"/>

Or expose the scripting variable as a scoped variable and use the
EL taglib:

    request.setAttribute("lang", lang);
    <fmt:setLocale value="${lang}" scope="session"/>
Comment 4 Pere Soler 2003-02-07 09:10:08 UTC
Thank you and sorry for my error.