Name
<x:forEach>
Synopsis
The
<x:forEach>
action evaluates its body once for each node in an XPath expression
evaluation result and sets the context node used by XPath expressions
in nested actions to the current node. The current node can also be
exposed to action elements in the body through a nested variable.
Syntax
<x:forEach select="XPathExpression
" [var="var
"] [varStatus="varStatus
"] [begin="startIndex
"] [end="stopIndex
"] [step="increment
"]>JSP elements
</x:forEach>
Attributes
Attribute name |
Java type |
Dynamic value accepted |
Description |
begin |
int |
Yes |
The first index, 0-based. |
end |
int |
Yes |
The last index, 0-based. If |
select |
String |
No |
The XPath expression. |
step |
int |
Yes |
Optional. Index increment per iteration. |
var |
String |
No |
The name of the nested variable holding the current element. |
varStatus |
String |
No |
The name of the variable to hold a |
Example
<x:forEach select="$doc//story"> <x:out select="title/text( )" /> </x:forEach>
Get JavaServer Pages, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.