John Sessler wrote:
> 
> 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.


Hummm... This error says that a dangling "scope" is not allowed for 
"setLocale" (i.e. having "scope" without "var"). However, I just checked the 
code for standard-1.0.2 and it *is* allowed (as the spec says).

Could you try the following simple JSP and tell us if you get the error
or not.

  <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"; %>
  <fmt:setLocale value="fr" scope="request"/>
  It works!


    -- Pierre



> 
>  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:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to