JSTL c:loop works but c:out doesn't  
Author Message
P.Hill





PostPosted: 2005-6-8 6:33:00 Top

java-programmer, JSTL c:loop works but c:out doesn't I have what I think is a weird config problem.
The following JSP
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<body>
<c:forEach var="i" begin="1" end="5" step="1">
<c:out value="${i}" />

<br />
</c:forEach>
</body>
</html>

produces:

${i}
${i}
${i}
${i}
${i}

instead of the expected
1
2
3
4
5

I'm on Tomcat 5.0
using JSTL 1.1.2
Placing jstl.lib and standards.lib in the app
tld files in app WEB-INF
which is defined in my web.xml
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>

What could be wrong?

-Paul
 
Wendy Smoak





PostPosted: 2005-6-8 6:40:00 Top

java-programmer >> JSTL c:loop works but c:out doesn't "P.Hill" <email***@***.com> wrote

> <c:forEach var="i" begin="1" end="5" step="1">
> <c:out value="${i}" /> <br />
> </c:forEach>

Try just
<c:forEach var="i" begin="1" end="5" step="1">
${i}<br/>
</c:forEach>

Your container is apparently evaluating the expression before it gets passed
to <c:out>.

You're correct that it's a configuration issue... I *think* it's controlled
by which dtd you specify in web.xml, but you probably don't want to drop
back to the prior version to "fix" this, just stop using <c:out> and use the
expressions directly.

--
Wendy Smoak


 
P.Hill





PostPosted: 2005-6-8 6:44:00 Top

java-programmer >> JSTL c:loop works but c:out doesn't P.Hill wrote:
>

Of course, 5 minutes after asking I find this:

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

I change my web.xml to start with web-app xmlns

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" ...

And the EL is evaluated!

Yeah!
-Paul