jstl foreach please help

Q

quickcur

Quick Function Jul 13 2004, 4:18 pm show options

Newsgroups: comp.lang.java.programmer
From: (e-mail address removed) (Quick Function) - Find messages by this
author
Date: 13 Jul 2004 16:18:04 -0700
Local: Tues, Jul 13 2004 4:18 pm
Subject: jstl does not work with foreach
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse

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
 
T

Tim Slattery

Quick Function Jul 13 2004, 4:18 pm show options

Newsgroups: comp.lang.java.programmer
From: (e-mail address removed) (Quick Function) - Find messages by this
author
Date: 13 Jul 2004 16:18:04 -0700
Local: Tues, Jul 13 2004 4:18 pm
Subject: jstl does not work with foreach
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse

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">

The forEach tag must have an "items" attribute which references a
collection. For instance:

<c:forEach items="${allxs}" var="x" begin="0" end="4" step="2">

allxs would be a collection. Elements of the collection would be
assigned to a variable named "x" each time through the loop.
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top