Home » JSTL x:choose,x:when,x:otherwise Tag

JSTL x:choose,x:when,x:otherwise Tag

by Online Tutorials Library

JSTL XML <x:choose>, <x:when>, <x:otherwise> Tags

The <x:choose> tag is a conditional tag that establish a context for mutually exclusive conditional operations. It works like a Java switch statement in which we choose between a numbers of alternatives.

The <x:when> is subtag of <x:choose> that will include its body if the condition evaluated be ‘true’.

The <x:otherwise> is also subtag of <x:choose> it follows <x:when> tags and runs only if all the prior condition evaluated is ‘false’.

The <x:when> and <x:otherwise> works like if-else statement. But it must be placed inside <x:choose> tag.

The syntax used for including the <x:choose;> tag is:

The syntax used for including the <x:when> tag is:

The syntax used for including the < x:otherwise > tag is:

Let’s see the simple example to understand the xml <x:choose>, <x:when>, <x:otherwise> tag:

Output:

Books Information:

Book is written by Brad Bird

JSTL XML Tags3

Next TopicJSTL <x:if> Tag

You may also like