Ok..lets say that I have some array of objects called APTJavaBeans in an arraylist AList. Please refer the code below - ArrayList AList = new ArrayList(); APTJavaBeans beans = new APTJavaBeans; ... .. //The array is populated with the bean objects //initialized or otherwise //now AList.add(beans); Now I have an array of beans kept in the session context. How do I iterate through this using <c:forEach..> tag in my JSP? Hope the qn is clear.
I admit, the Docs on JSTL are still weak. You are in luck on one point. CHAPTER 5 - Controlling flow with loops of Shawn Bayern's book "JSTL in Action" is on line. For a quick run down, ForEach has the following attributes: items - the actual collection that will be iterated over begin - the index to start the iterator at. end - the index to end at step - step the iterator takes var - the name of the variable that will hold the item returned from each iteration. varStatus - ?? hum I need to do somemore digging on this one.
AHA! Some digging through the source code and..... varStatus sets the name of the variable that you can use to access through EL to get to the LoopTagStatus Object within the Tag. Provides the following methods for you to check. getBegin() - Returns the value of the 'begin' attribute for the associated tag, or null if no 'begin' attribute was specified. getCount() - Retrieves the "count" of the current round of the iteration. getCurrent() - Retrieves the current item in the iteration. getEnd() - Returns the value of the 'end' attribute for the associated tag, or null if no 'end' attribute was specified. getIndex() - Retrieves the index of the current round of the iteration. getStep() - Returns the value of the 'step' attribute for the associated tag, or null if no 'step' attribute was specified. isFirst() - Returns information about whether the current round of the iteration is the first one. isLast() - Returns information about whether the current round of the iteration is the last one. This allows you to do some decissions for such things as paging, Display something different for the first/ last item only etc.