Format Date with fmt:formatDate JSP

Sergio del Amo picture Sergio del Amo · Nov 11, 2008 · Viewed 53.7k times · Source

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

Answer

lucas picture lucas · Nov 11, 2008

Try

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