Link to home
Start Free TrialLog in
Avatar of sharath_kulal
sharath_kulalFlag for United States of America

asked on

Struts Form containing Vector

My Struts Form Contains a vecotor. how do i display the contents of the Vector using struts iterate?
Avatar of kiranhk
kiranhk

<logic:iterate id="vector" name="myHash" type="java.util.Vector">
<logic:iterate id="myVal" name="vector" type="java.lang.Whatever">
//do something
</logic:iterate>
</logic:iterate>

-----------------
or try
-----------------
<logic:iterate id="myVal" collection="<%= vector %>" type="java.lang.Whatever">
//do something
</logic:iterate>



Note: neither of these were tested.
ASKER CERTIFIED SOLUTION
Avatar of vsaritha_9
vsaritha_9

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If the elements in the Vector are Strings, I don't think you need to specify a property.

Example:
<logic:iterate id="elementId" name="yourVector" type="java.lang.String">
   <bean:write name="elementId"/>
</logic:iterate>

yes your right, Property is required if the collection contains javabean

Thank you for correcting me
Hi sharath_kulal,

Well, I hope that my example can help you to understand how to iterate vector in JSP using iterate tags.

<html>

<%
    Vector a = new Vector();
    a.add("1");
    a.add("2");
   
    request.setAttribute("Vector", a);
%>
<body class="bodycontent">
<logic:iterate id="test" name="Vector">
    <bean:write name="test" />
</logic:iterate>
</body>
</html>

Thanks.

Regards
Dave