How to use <logic:iterate> strut tag to loop arrayList that holds other arrayList

Posted on 2007-04-05
Last Modified: 2013-11-24
Hi, I set in request “arrayListParent” that holds a couple of “arrayListChildren.  I know how to loop through one arraylist using <logic:iterate>, but in this case, I have an arraylist holding other arrayList.  I have pasted my current jsp code on the bottom that uses scripting to display the arraylist and it’s children, that works fine.  But can anyone provide me an example to do that using controls like code directly below here?
Thanks so much for your help,
 ********* Version with jsp tag controls *******
<logic:iterate id="courses" name="arrayListParent" scope="request"
            ……..//Have no idea how to get arrayListChildren            
************** Current version in JSP*********
    ArrayList arrayListParent = (ArrayList)request.getAttribute( “arrayListParent”);
    ArrayList attendees = new ArrayList();
    Iterator iterator = arrayListParent.iterator();
    Attendee attendee = new Attendee();        
      for (int i = 0; iterator.hasNext();i++) {
          attendees = (ArrayList);
          Iterator iterator2 = attendees.iterator();
          for(int j = 0; iterator2.hasNext();i++) {
              attendee = (Attendee);              
              %><%= attendee.getLastName()%>,<%=attendee.getFirstName()%>              

Question by:noijet
  • 2
  • 2
LVL 10

Assisted Solution

Jaax earned 30 total points
ID: 18857957

Author Comment

ID: 18858342
Hi Jaax, thanks for your reply:
  Reading that message: I can do:
<logic:iterate id="parent" name="arrayListParent" scope="request"
           <logic:iterate id="child" name="arrayListChildren"   type="java.util.ArrayList">
                  <bean:define name="child" property="firstname"/> ,  
                  <bean:define name="child" property="firstname"/>  
***My question is "arrayListChildren" holds a list of objects of type Child that has properties firstname and lastname, the above code would work right?

LVL 11

Expert Comment

ID: 18862513
Inside it, again use logic iterate tag.
LVL 11

Accepted Solution

Manish earned 95 total points
ID: 18862540
Can you try this..?
 <logic:iterate id="child" name="arrayListChildren"   type="com...Attendee">

Author Comment

ID: 18864872
Hi all, I will try out suggestions and get back you you!

Thanks again,

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
withoutTen challenge 14 99
hasOne  challenge 59 126
pairstar challenge 2 53
egit plugin on eclipse 8 37
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

911 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

15 Experts available now in Live!

Get 1:1 Help Now