I expected multiple-level nesting with the <logic:iterate> tag in Struts to be difficult, but on the contrary it turned out to be an almost trivial exercise.

In my case/this example, we get from the data tier a list of books in a form bean as a collection of BookDTOs (Data Transfer Objects). A BookDTO contains fields such as title, publisher, year and a collection of authors (second iterator!), which in turn contains fields such as first name, last name and initials.

The JSP fragment is as follows:

&lt;%@ page language="java" %&gt;
&lt;!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en"&gt;
&lt;%@ taglib uri="/tags/struts-html" prefix="html"%&gt;
&lt;%@ taglib uri="/tags/struts-bean" prefix="bean"%&gt;
&lt;%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %&gt;
&lt;logic:greaterThan property="numResults"
                   name="publicationsFormBean"
                   value="0" &gt;
  &lt;h3&gt;Books in database:&lt;/h3&gt;
  &lt;ol&gt;
    &lt;logic:iterate
     name="publicationsFormBean"
     property="publications"
     indexId="i"
     id="dummy"&gt;
      &lt;li&gt;
        &lt;i&gt;
          &lt;bean:write
           name="publicationsFormBean"
           property='&lt;%= "publications["+ i +"].title" %&gt;'/&gt;
        &lt;/i&gt;,
        &lt;logic:iterate name="publicationsFormBean"
         property='&lt;%= "publications["+ i +"].authors" %&gt;'
         indexId="j"
         id="dummy2"&gt;
          &lt;bean:write
           name="publicationsFormBean"
           property='&lt;%= "publications["+ i +"].authors["+ j +"].initials" %&gt;'/&gt;
          &lt;bean:write
           name="publicationsFormBean"
           property='&lt;%= "publications["+ i +"].authors["+ j +"].lastName" %&gt;'/&gt;
         (&lt;bean:write
           name="publicationsFormBean"
           property='&lt;%= "publications["+ i +"].authors["+ j +"].firstName" %&gt;'/&gt;
          &lt;bean:write
           name="publicationsFormBean"
           property='&lt;%= "publications["+ i +"].authors["+ j +"].middleNames" %&gt;'/&gt;),
        &lt;/logic:iterate&gt;
        &lt;bean:write
         name="publicationsFormBean"
         property='&lt;%= "publications[" + i + "].publisher" %&gt;'/&gt;,
        &lt;bean:write
         name="publicationsFormBean"
         property='&lt;%= "publications[" + i + "].year" %&gt;'/&gt;
      &lt;/li&gt;
    &lt;/logic:iterate&gt;
  &lt;/ol&gt;
&lt;/logic:greaterThan&gt;

Note how in the second iterator (with indexId=j) the property is desginated a collection in a collection. From there the properties can be addressed straightforwardly by separating them with dots.

This results in an output as follows:

  1. Book title one, J.W. Klaassen (Jan Willem), My Publisher, 2004
  2. Book title two, J.W. Klaassen (Jan Willem), P. Puk (Pietje), My Publisher, 2004