Search code examples
javajspjstlscriptlet

Why can I not transfer a scriptlet attribute to JSTL in this JSP custom tag?


The string:

${prettyDate}

is output to the page by this custom tag instead of the prettified Date string:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ tag import="com.ocpsoft.pretty.time.PrettyTime, java.util.Date"%>
<%@ attribute name="dateParam" required="true" type="java.util.Date" %>

<%
 PrettyTime p = new PrettyTime();
 String prettyDate = p.format(dateParam);
 jspContext.setAttribute("prettyDate", prettyDate);
%>
<c:out value="${prettyDate}"/>

Why am I doing that prevents the scriptlet attribute (prettyDate) from being transferred to the JSTL in this JSP custom tag?


Solution

  • What version is your web application? If somehow you are still using JSP 1.2, you have to explicitly set the isELIgnored page directive to false.