tags:

views:

38

answers:

2
+3  Q: 

Vector in JSP page

How I can iterate a vector in a JSP page?

I have done it:

<%
 Vector value = (Vector) request.getAttribute("status");
 for (Enumeration e = value.elements(); e.hasMoreElements(); )
 {
        StatusItem myStatus = (StatusItem) e.nextElement();

 }
%> 

Is there any way to do it with jsp tags? Thx

+1  A: 

You can iterate collections by <c:forEach> jstl tag:

<c:forEach var="s" items="${status}">
    item is: ${s}
</c:forEach>
Bozho
+2  A: 

Print out the contents of the vector like this:

<c:foreach var="myStatus" items="${status}" >
  <!-- print out the value of each status in the vector.
       Method getValue() must exist in the status class.-->
  <c:out value="${myStatus.value}"/>
</c:foreach>
dogbane