If I understand your question, you essentially have an ArrayList of ArrayLists. JSTL has some fairly odd rules for what a valid "items" "collection" is. This wasn't sufficiently answered by the JSTL 1.2 specification so I went to the source code.
forEach can iterate over:
- An array of native or Object types (Note: this includes any generic arrays because of type erasure);
- Collection or any subclass;
- Any Iterator;
- An Enumeration;
- Anything implementing Map; or
- Comma-serparated values as a String. This is deprecated behaviour.
Word of caution: use of Iterators and Enumerations in this context is potentially problematic as doing so modifies their state and there's no way to reset them (via JSTL).
Anyway, the code is straightforward:
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<c:forEach var="event" items="${events}">
<c:forEach var="date" items="${event}">
<fmt:formatDate value="${date}" type="both"
timeStyle="long" dateStyle="long" />
</c:forEach>
</c:forEach>
Assuming the event object is merely a collection of dates. If that collection is a property then just replace ${event}
with ${event.dates}
or whatever.