Hi List,

it seemed clear to me, that this construct:

  <c:forEach items="${t.records}" var="x">
     ... (some inner logic)
  </c:forEach>
 
should be equivalent to this one:

  <%
  for (Iterator it=t.getRecords(); it.hasNext(); ) {
     String x = (String)it.next();
  %>
     ... (some inner logic)
  <% }
  %>

But the forEach-version is not working as expected. What can be wrong?
Here are some quite strange effects:
1. The iterators-method "hasNext()" is called twice for every iteration
    (ok: no problem, if the iterator is clean, but why?)
2. The loop-body is executed after hasNext() returned false.
    But the next()-method is NOT called ??

The c:forEach-iterator seems to operate like this:

Iterator it = t.getRecords();
while (it.hasNext()) {
        String x = (String)it.next();
        boolean still_more = it.hasNext();

        ... here comes the body ...
}

What could this extra-check be good for?

Any help is greatly appreciated.
Kind regards,

Reinhard

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to