JSTL Core c:choose

The <c:choose> works like a Java switch statement it allows to check an expression with various conditions. <c:choose> has <c:when> sub-element to allow you to check an expression. There  can be multiple <c:when> in single <c:choose>.This tag has <c:otherwise> sub-element like default clause in switch case.



<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<title><c:choose> Tag Example</title>
<c:set var="num" scope="request" value="2"/>
 <c:when test="${num eq 1}">
Num has value 1
 <c:when test="${num eq 2}">
Num has value 2
No value matched

Leave a Reply