Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

forEach: print something if empty

843838Aug 21 2005 — edited Aug 21 2005
Hi All,

I can do the following to iterate over a collection.
<c:forEach var="currentErrorFile" items="${errorsCommandBean.errorFiles}" >
  <c:out value="${currentErrorFile.absolutePath}" />
</c:forEach>
I want to include some code to print out a message if the collection is empty.

I was thinking to do it by making a JSTL level variable first so that I don't end up calling errorsCommandBean.getErrorFiles() twice. My problem is that this calls errorsCommandBean.getErrorFiles() which (by design) does some work to retrieve the files: it doesn't just return a reference.

I can't work out how to get a variable like this. Either useBean/set tags don't do it or I have misunderstood them.

Any help would be most appreciated!

Rob
:)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 18 2005
Added on Aug 21 2005
2 comments
305 views