• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

JSTL forEach tag

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am using Tomcat 5.0.18 , WinXP and J2sdk1.4.2_03
I installed standard tag libray from jakarata.apache.org. following code snippet shows the use of forEach tag.
<%@ taglib uri="http://jakarta.apache.org/taglibs/core"; prefix="c" %>
<html>
<head>
<title>Count to 10 Example(using JSTL)</title>
</head>
<body>
<c:forEach var="i" begin="1" end="10" step="1">
<c ut value="${i.value}" />
</br>
</c:forEach>
</body>
</html>
Now instead of priting values from 1 to 10 it prints {i.value} string !!!
why it is not priting numbers ???
Can anybody help
thanks
-Anand
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anand,
you have to use <c ut value="${i}" />
not <c ut value="${i.value}" />
-Mouli.
 
Anand Gondhiya
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mouli,
I tried <c ut value="${i}" /> but same problem !
It gives {i} in output and not the values of i !
thanks
-Anand
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

try this instead.
It might still not work as c:forEach iterates over a List and you supply a List (but this might be a form I haven't seen before).
 
Anand Gondhiya
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeroen,
thanks.
I tried the piece of code you supplied. Same problem persists !
now it prints ${v.count} on the output !
any clues ? Thanks for your help
-Anand
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By default, the EL evaluation is enabled for Web Applications using
a Servlet 2.4 or greater web.xml, and disabled otherwise.
you can make your web.xml like this to enable EL:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
version="2.4">
</web-app>
and BTW: you can just use ${i} instead of <c: out value="${i}" />.
[ March 20, 2004: Message edited by: Eric Suen ]
 
Anand Gondhiya
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Eric,
Thanks a bunch ,it works now !!
I digged everywhere but couldn't find the solution.
thanks again..
-Anand.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic