Name

<x:when>

Synopsis

The <x:when> action represents one of the mutually exclusive alternatives within a <x:choose> block. It evaluates its body only if it’s the first <x:when> action in the block with a test expression that evaluates to true.

Syntax

<x:when select="booleanXPathExpression">
  JSP elements
</x:when>

Attributes

Attribute name

Java type

Dynamic value accepted

Description

select
String

No

The test XPath expression

Example

<x:choose>
  <x:when select="category[. = 'General']">
    <td bgcolor="lightgreen">
  </x:when>
  <x:otherwise>
    <td>
  </x:otherwise>
</x:choose>

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.