• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL 1.0 : forEach error

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using JSTL <b>1.0</b>,

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<c:forEach var="eachObject" items="<%=allData%>">
<td><c ut value="${eachObject}" /></td>
<td><c ut value="${eachObject.Id}" /></td>
</c:forEach>

but the output is "${eachObject}" and "${eachObject.Id}". Sounds like it doesn't work. But I have jstl.jar there.

Thanks
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try something simpler to see the tags work?

Did you try using ${ } instead of <%= %> ?



Your code snippet doesn't show what scope allData is declared in.

If you've got some existing jsp's and you're trying to slip in some jstl as a starting point, your allData list is probably declared in a scriptlet and is not visible using ${}. You can get around that a couple of different ways. One way to get things rolling is to use pageContext.setAttribute()...see code snippet:



[ May 23, 2005: Message edited by: Carol Enderlin ]
[ May 23, 2005: Message edited by: Carol Enderlin ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!