tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Sessler" <jsess...@sistemas-jasper.com>
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
message:

 error:null(-1,-1) <h3>jsp.error.tlv.invalid.page</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,
 Win2k


 The jsp is a minor variation of the struts example program (index.jsp). The
 minor variation is from

http://developer.java.sun.com/developer/technicalArticles/Intl/MultilingualJ
 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">
 <head>
 <title><bean:message key="index.title"/></title>
 <html:base/>
 </head>
 <body bgcolor="white">

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

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

 <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" />
 </c:if>


 <%-- 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):
   <taglib>
     <taglib-uri>/WEB-INF/jstl-core.tld</taglib-uri>
     <taglib-location>/WEB-INF/c.tld</taglib-location>
   </taglib>
   <taglib>
     <taglib-uri>/WEB-INF/jstl-fmt.tld</taglib-uri>
     <taglib-location>/WEB-INF/fmt.tld</taglib-location>
   </taglib>

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

 I have tried the suggestion of using http://java.sun.com/jstl/fmt 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
 internationalized.
 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,
 John



--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message