Weird error with taglib

[nobr]Hello, I'm getting this weird error. Sometimes when I'm using taglibs I get org.apache.jasper.JasperException: /mypage.jsp(11,4) According to TLD or attribute directive in tag file, attribute value does not accept any expressions. I refresh the page, and it displays, refresh again and the error is there again, this keeps happening randomly.

In this post I found a solution http://forum.java.sun.com/thread.jspa?threadID=683007&messageID=9423383, changing the taglib to the "_rt" works, but some guy says this is not a preferred solution.

This is my code without the "fix":

<%@page contentType="text/html"%>

<%@page pageEncoding="UTF-8"%>

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

<%@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><fmt:message key="appTitle"/></title>

</head>

<body>

<h3><fmt:message key="news"/></h3>

<c:forEach items="${model.news}" var="news">

<strong><c:out value="${news.title}"/></strong> - <i> <fmt:formatDate value="${news.daten}" pattern="dd/MM/yyyy"/> </i> - <a href="<c:url value="deleteNews.htm?newsId="/><c:out value="${news.id}"/>">Delete</a> - <a href="<c:url value="editNews.htm?newsId="/><c:out value="${news.id}"/>">Edit</a> <br>

<c:out value="${news.content}"/><br>

<small>Source:<c:out value="${news.source}"/></small>

</c:forEach>

<a href="<c:url value="addNews.htm"/>">Add News</a>

</body>

</html>

How can I fix this issue using the normal taglibs?

Thanks in advance[/nobr]

[2857 byte] By [Martin_Castellanosa] at [2007-11-27 2:34:28]
# 1

You seem to be mixing the versions of JSTL taglibs in your page.

For the c taglib you are using the JSTL1.1 URI

For the fmt taglib you are using the JSTL1.0 URI

Change the import line to use the JSTL1.1 URI, and you should be set

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

(note the subtle change with /jsp in there)

As I mentioned in the other post, use of the _rt taglib should be restricted to JSP1.2 containers (eg Tomcat4)

In JSP2.0 containers (Tomcat5+) you should use JSTL1.1, and it should work perfectly, provided your web.xml file is up to date.

Some other posts on the subject you might find useful, that explain why the JSTL1.0 tags did not accept runtime expressions:

http://forum.java.sun.com/thread.jspa?threadID=628740

http://forum.java.sun.com/thread.jspa?threadID=629437&tstart=0

Cheers,

evnafets (some guy)

evnafetsa at 2007-7-12 2:51:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thanks! that did it.
Martin_Castellanosa at 2007-7-12 2:51:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...