try {
_iterator = null;
_index = 0;
_count = 0;
PageContextImpl pageContext = (PageContextImpl) this.pageContext;
ELContext env = pageContext.getELContext();
if (_beginExpr != null)
_begin = (int) _beginExpr.evalLong(env);
else
_begin = -1;
if (_endExpr != null)
_end = (int) _endExpr.evalLong(env);
else
_end = Integer.MAX_VALUE;
if (_stepExpr != null)
_step = (int) _stepExpr.evalLong(env);
else
_step = 0;
Object items = null;
if (_itemsExpr != null) {
items = _itemsExpr.evalObject(env);
_iterator = getIterator(items);
while (_index < _begin && _iterator.hasNext()) {
_index++;
_iterator.next();
}
}
else if (_beginExpr == null)
throw new JspException(L.l("c:forEach must specify `items' or `begin'"));
else if (_endExpr == null)
throw new JspException(L.l("c:forEach must specify `items' or `begin'"));
else {
_iterator = new RangeIterator(_begin, _end);
_end = -1;
}
if (_varStatus != null)
pageContext.setAttribute(_varStatus, this);
if (_var != null)
_initialVar = pageContext.getAttribute(_var);
return doAfterBody();
} catch (Exception e) {
throw new JspException(e);
}