jstl does not work with foreach

Q

Quick Function

I am testing jstl, here is my jsp:

<%@ page language="java" contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<html>
<body>
<table border=1>
<tr>
<th>Value</th>
<th>Square</th>
</tr>
<c:forEach var="x" begin="0" end="4" step="2">
<tr>
<td><c:eek:ut value="${x}"/></td>
<td><c:eek:ut value="${x * x}"/></td>
</tr>
</c:forEach>
</table>

</body>
</html>

But the output in web broswer is :

Value Square
${x} ${x * x}
${x} ${x * x}
${x} ${x * x}


Why?

Thanks,

qq
 
M

Murray

But the output in web broswer is :
Value Square
${x} ${x * x}
${x} ${x * x}
${x} ${x * x}


Why?

Thanks,

qq

Your example works fine for me (using Tomcat 5). Sounds like a configuration
issue. Is it possible that you're using the core_rt library instead of the
standard EL core?
 
M

Murray

Murray said:
Your example works fine for me (using Tomcat 5). Sounds like a configuration
issue. Is it possible that you're using the core_rt library instead of the
standard EL core?

Does something as simple as <c:eek:ut value="${1 + 2}"/> work?
 
Q

Quick Function

Murray said:
Your example works fine for me (using Tomcat 5). Sounds like a configuration
issue. Is it possible that you're using the core_rt library instead of the
standard EL core?

I am using tomcat 5 too.

Here is my web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
</web-app>

I copy all tlb files from C:\jakarta-taglibs\standard\tld to my
WEB-INF and jstl.har and standard.jar to my WEB-INF\lib.
 
Q

Quick Function

Murray said:
Does something as simple as <c:eek:ut value="${1 + 2}"/> work?

No it doesn't. It print out "${1 + 2}";

I think it is some configuration. Here is my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<taglib>
<taglib-uri>/WEB-INF/c.tld</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/c.tld</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/fmt.tld</taglib-uri>
<taglib-location>/WEB-INF/fmt.tld</taglib-location>
</taglib>
</web-app>

I copied all tld files download to WEB-INF and jstl.jar and
standard.jar to WEB-INF/lib.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top