Struts Form containing Vector

Posted on 2004-11-24
Last Modified: 2012-06-21
My Struts Form Contains a vecotor. how do i display the contents of the Vector using struts iterate?
Question by:sharath_kulal
    LVL 8

    Expert Comment

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

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

    Note: neither of these were tested.

    Accepted Solution

    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"/>

    Hope this helps

    Expert Comment

    If the elements in the Vector are Strings, I don't think you need to specify a property.

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


    Expert Comment

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

    Thank you for correcting me
    LVL 16

    Expert Comment

    Hi sharath_kulal,

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


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



    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
    Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now