Name

<x:forEach>

Synopsis

The <x:forEach> action evaluates its body once for each node in an XPath expression evaluation result, which 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"]>
  JSP elements
</x:forEach>

Attributes

Attributename

Java type

Dynamic valueaccepted

Description

select
String

No

The XPath expression

var
String

No

The name of the nested variable holding the current element

Example

<x:forEach select="$doc//story">
  <x:out select="title/text( )" />
</x:forEach>

Get JavaServer Pages, Second 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.