tags:

views:

9709

answers:

6

I am trying to format a date with:

<fmt:formatDate value="${newsletter.createdOn}" pattern="MM/dd/yyyy"/>

newsletter is an object with a createdOn property which is java.util.Date.

When I invoke the previous sentence I get:

According to the TLD, the attribute value does not accept expressions.

I am importing fmt with

<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>

Does anyone know how can I work around this problem?

I am using the jstl.jar coming with tomcat.

Under jstl.jar/META-INF/MANIFEST.MF stays:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.5.3 
Created-By: 1.4.2-b28 (Sun Microsystems Inc.)
Specification-Title: JavaServer Pages Standard Tag Library (JSTL)
Specification-Version: 1.1
Implementation-Title: JavaServer Pages Standard Tag Library API Refere
 nce Implementation
Implementation-Version: 1.1.0-D13
Implementation-Vendor: Sun Microsystems, Inc.
Implementation-Vendor-Id: com.sun
Extension-Name: javax.servlet.jsp.jstl

I am using Apache Tomcat Version 6.0.14

+1  A: 

Are you sure you're not using the runtime versions of the tag lib? May we see the library import statement?

I think lucus is onto something, according to this FAQ on JavaRanch, that's a JSTL 1.0 declaration. You might want to update to 1.1.

What's your environment, app server, and version?

sblundy
added in the main question
Sergio del Amo
Do you know what version you're using?
sblundy
updated the main question
Sergio del Amo
A: 

Try

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
lucas
A: 

Are you using the fmt-1_0-rt.tld or fmt-1_0.tld taglib.

The difference is the settings for rtexprvalue

In one, this is false, in the other it is true.

toolkit
No idea, how can i know this. I am using the jstl.jar where this tags are defined.
Sergio del Amo
+1  A: 

Are you using JSTL 1.0 or 1.1? formatDate in 1.1 should accept expressions.

Michael Glenn
i think jstl 1.1
Sergio del Amo
A: 

Apparently, i needed 1.1 but i had to change the library import statements for both c and fmt.
Now it works. Thanks for the help, and sorry for the confusion.

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
Sergio del Amo
+2  A: 

This guy seems to have worked around the problem by extracting the TLD from the jar, modifying it, placing it in the WAR's WEB-INF directory, and adding an entry to his web.xml like this:

<jsp-config>
 <taglib>
  <taglib-uri>http://java.sun.com/jstl/fmt&lt;/taglib-uri&gt;
  <taglib-location>/WEB-INF/fmt.tld</taglib-location>
 </taglib>
</jsp-config>

In the end, he switched to the 1.1 declaration:

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"/>
sblundy
problem is solved sblundy. Thanks for your help. You rock!
Sergio del Amo