You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Scott Goldstein <sd...@mailandnews.com> on 2003/04/21 06:17:58 UTC

forEach and empty collection

Is there an easy way to print alternative text when an iteration is
empty when using forEach.  Example:

<c:forEach items="${requestScope.items}" var="item">
    <c:out value="${item}"/>
</c:forEach>

This lists the items in the collection.  But, what if I would like to
print, "Sorry, no items" when the "items" iterator is empty?  Would I
have to use a <c:if> before the <c:forEach>, or is there an better way?

Thanks.

Scott



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org