tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Sessler" <>
Subject fmt:setLocale Revisited
Date Thu, 05 Dec 2002 09:50:42 GMT
Hello All,

 I am experiencing the same problem described by someone else in Oct.
 however, the solutions suggested do not work for me. When compiling a page
 with the fmt:setLocale tag the compiler reports the following error

 error:null(-1,-1) <h3></h3><p>8: Illegal scope
 attribute without var in "fmt:setLocale" tag.

 Environment: jdk1.4.0_01-b03, Jakarta-Tomcat 4.1.12-LE-jdk1.4,
 jakarta-taglibs-standard-1.0.2 (JSTL), jakarta-struts-1.0.2, JBuilder6,

 The jsp is a minor variation of the struts example program (index.jsp). The
 minor variation is from
 SP/  (watch out for the typos in the code) and allows the user to set the
 language for the web page. Here is the relevant part of jsp page:

 <%@ page contentType="text/html;charset=UTF-8" language="java" %>
 <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
 <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
 <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
 <%@ taglib uri="/WEB-INF/jstl-core.tld" prefix="c" %>
 <%@ taglib uri="/WEB-INF/jstl-fmt.tld" prefix="fmt" %>

 <html:html locale="true">
 <title><bean:message key="index.title"/></title>
 <body bgcolor="white">

 <logic:notPresent name="database" scope="application">
   <font color="red">
     ERROR:  User database not loaded -- check servlet container logs
     for error messages.

 <logic:notPresent name="org.apache.struts.action.MESSAGE"
   <font color="red">
     ERROR:  Application resources not loaded -- check servlet container
     logs for error messages.

 <h3><bean:message key="index.heading"/></h3>

 <%-- Interpret user's locale choice --%>

 <c:if test="${param['locale'] != null}">
   <fmt:setLocale value="${param['locale']}" scope="session" />

 <%-- Offer locale choice to user --%>
 <a href="index.jsp?locale=en">English</a> -
 <a href="index.jsp?locale=es">Castellano</a> -
 <a href="index.jsp?locale=fr">Francais</a>

 Here is the relevant portion of web-xml (struts taglibs not shown):

 The page works (displays internationalized content) using bean:message but
 want to use fmt:message because the latter accepts objects from the
 expression language as the value for the key while bean:message accepts
 hardcoded strings, as I understand.

 I have tried the suggestion of using in the
 taglib directive but the compiler reports a NullPointerException (no
 indication of where). Curiously, my environment disallows running the page
 with the "Illegal scope attribute without var in "fmt:setLocale" tag" error
 but does allow the page to run with the NullPointerException. Even though
 the page runs after the NullPointerException messages are not
 Both reported errors are exclusive to the statement <fmt:setLocale
 value="${param['locale']}" scope="session" />. If removed the page compiles
 and runs, without the user selected locale of course.

 I have tried many variations of the taglib directive but this doesn't solve
 the problem. I have checked the libraries available during compilation but
 have yet to discover a missing library (obviously).

 Can someone:
 Point out a simple but complete working example (other than the reference
at  Sun already mentioned) which uses the fmt:setLocale tag?
 Give me some insight on why the setLocale tag looks for a var attribute
when  var is not an acceptable attribute for the setLocale tag?
 Suggest something else to to try?

 Thank you in advance,

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message