Dear all, i m using dao design pattern in which i m returning a arraylist object ,inside object i can fetch by typecasting object into class and acees the getters like object.getName(),i want to itearate using a jstl tags.how can i do that.
+2
A:
<c:forEach items="${yourArrayList}" var="item">
<c:out value="${item.name}" />
</c:forEach>
The objects you put in your collection should conform to the JavaBeans specification (for ex. all of their properties should be accessible via getter methods).
${yourArrayList}
is actually a request attribute that you have put from a servlet and then forwarded to the jsp.
Bozho
2010-04-20 09:05:18
A:
Ok with Bozho.
I will just say that if you redirect a servlet to jsp (which is better than calling dao from scriptlets...) don't forget to put your object that will be used in jstl in a pagecontext scope like request or session. Without that jstl lib would never find your object...
Sebastien Lorber
2010-04-20 11:32:38