Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Iterate over a Vector in a JSP page ?

843836Apr 4 2005 — edited Apr 6 2005
Hello All.

I have seen other posts on this issue, but I still dont seem to see how it is done.

I need to iterate over a Vector (java.util.Vector) in a JSP page, preferebly using JSTL (not mandatory). The vector is constructed in a java Bean.

The code is like this:

The part of code from the java Bean (implemented as an action):
// results is defined as:
java.util.Vector results;
//...
// cursor iterates through some data obtained elsewhere
while (cursor.hasMore()) {
            String[][] info = new String[set.size()][2];
            for (int i=1; i<set.size(); i++) {
                info[0] = "name"; // sample value, not real
info[i][1] = "a value"; // sample value, not real
}
results.add((String[][])info);
}


Then I have a method to get the data (also in the java bean):
public Vector getResults() {
        return results;
}
Then in the JSP page I have:
<jsp:useBean id="beanGis" class="bean.ServidorMapa" scope="application"/>
<c:set var="myResults" value="${beanGis.results}"/>

<c:forEach var="row" items="${myResults}"
   <c:out value="${row.info}"/>    <%-- THIS DOWS NOT WORK --%>
</c:forEach>
How can I iterate through the vector.

I think a possible solution may be to create a Class to wrap my String matrixes in (the info String[][]), and use a getter/setter. But, is there a direct way in JSTL?, if not is class wrapper the right way to go ?

Thanks, Have fun.

Mark Sanchez.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 4 2005
Added on Apr 4 2005
2 comments
201 views