Javatpoint Logo
Javatpoint Logo

JSTL Core <c:choose>, <c:when>, <c:otherwise> Tag

The < c: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 <c:when > is subtag of <choose > that will include its body if the condition evaluated be 'true'.

The < c:otherwise > is also subtag of < choose > it follows &l;twhen > tags and runs only if all the prior condition evaluated is 'false'.

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

JSTL Core <c:choose>, <c:when>, <c:otherwise> Example

Let's see the simple example of < c:choose >, < c:when > < c:otherwise > tag:

This will produce the following result:

JSTL Core Tags6

Even/Odd Example using c:when and c:otherwise

Output:






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA