Struts Form containing Vector

My Struts Form Contains a vecotor. how do i display the contents of the Vector using struts iterate?
LVL 1
sharath_kulalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kiranhkCommented:
<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.
0
vsaritha_9Commented:
Where is your Vector?
Is it in Session scope or request scope?
if you don't specify scope attribute in logic:iterate then it looks for your vector in session scope.

<logic:iterate id="mList" scope="session"  name="yourVectorName" type="data type of objects that vector holds">

For Example:
If your vector contains  the collection of descriptions of type String and it is named as myVector and added to the session scope then you logic:iterate tag would look like this

<logic:iterate id="mList" scope="session"  name="myVector" type="java.lang.String">
   <bean:write  name="mList" property="description"/>
</logic:iterate>

Hope this helps
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ClazzeFlitsCommented:
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>

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

Thank you for correcting me
0
suprapto45Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.