glassfish_at_javadesktop.org wrote On 03/25/07 12:22 PM,:
>I am trying to deploy a very simple JSP using the JSTL <fmt:formatDate> tag. I am using Glassfish V2 beta.
>
>The body of the JSP is:
>[code]
><%@ page language="java" contentType="text/html; charset=UTF-8"
> pageEncoding="UTF-8"%>
><%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
><html>
><head>
><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
><title>FormatDate</title>
></head>
><body>
><jsp:useBean id="rightNow" scope="page" class="java.util.Date" />
><fmt:formatDate value="${rightNow}" />
></body>
></html>
>[/code]
>It follows an example in the Java EE 5 tutorial pretty closely (the example can be found in page 194 of the PDF version of the Java EE 5 tutorial).
>
>When I deploy the war file containing the JSP and point the browser to it, I get the following error message:
>
>org.apache.jasper.JasperException: /formatDate.jsp(12,0) PWC6236: According to TLD or attribute directive in tag file, attribute value does not accept any expressions
>
>note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server 9.1 logs.
>
>>From the example, it looks like the value attribute should accept expressions. I opened appserv-jstl.jar, which contains JSTL tlds and code, and opened the version of fmt.tld inside that jar file. The relevant section looks like this:
>
>
The taglib URI you are referencing from your JSP page:
http://java.sun.com/jstl/fmt
is from JSTL 1.0, when the Expression Language (EL) was still part of
JSTL and not (yet) part of the JSP container.
The above URI is declared in this TLD file:
fmt-1_0.tld (and not in fmt.tld!)
where the "value" attribute of <formatDate> is declared to not accept
any rt expressions:
<tag>
<name>formatDate</name>
<attribute>
<name>value</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
...
</tag>
which is why you have been getting this error:
According to TLD or attribute directive in tag file, attribute value does not accept
any expressions
Remember, in JSTL 1.0, ${rightNow} is passed unevaluated to the
<formatDate> tag handler, which is responsible for evaluating it.
There are two possible fixes to prevent the error you are getting:
- Replace
"
http://java.sun.com/jstl/fmt"
with
"
http://java.sun.com/jsp/jstl/fmt"
from JSTL 1.1, which is defined in "fmt.tld" and which declares the
"value" attribute
of <formatDate> to accept expressions, or
- Keep using the "
http://java.sun.com/jstl/fmt" from JSTL 1.0, but use
a Servlet 2.3 based web.xml. The Servlet 2.3 based web.xml will
disable the EL machinery of the JSP container, and pass "${rightNow}" as
a string value to the <formatDate> tag handler, for it to evaluate it.
Jan
>[code]
><tag>
> <description>
> Formats a date and/or time using the supplied styles and pattern
> </description>
> <name>formatDate</name>
> <tag-class>org.apache.taglibs.standard.tag.rt.fmt.FormatDateTag</tag-class>
> <body-content>empty</body-content>
> <attribute>
> <description>
>Date and/or time to be formatted.
> </description>
> <name>value</name>
> <required>true</required>
> <rtexprvalue>true</rtexprvalue>
> </attribute>
>[/code]
>
>It is my understanding that if rtexprvalue is set to true, then the attribute should accept EL expressions.
>
>Did I just find a bug in Glassfish or am I doing something wrong?
>
>Any help greatly appreciated.
>[Message sent by forum member 'eraser' (eraser)]
>
>http://forums.java.net/jive/thread.jspa?messageID=209779
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>