JSTL - jstl core choose
<prefix:choose> ये tag; <prefix:when> और <prefix:otherwise> tag का parent tag होता है | इस tag के अन्दर इनके child tags के साथ conditional operations किये जाते है |
<prefix:choose> इस tag में दिए गए दो tags elseif statement के जैसे होते है |
Syntax for <prefix:choose> in JSTL
<prefix:choose> <prefix:when test=${expression}> --- </prefix:when> <prefix:otherwise> <%--this tag is optional --%> --- </prefix:otherwise> </prefix:choose>
<prefix:choose> Attribute in JSTL
<prefix:choose> tag के लिए कोई attribute नहीं होता है |
Example for <prefix:choose> Tag in JSTL
Source Code :Output :<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <% int a = 10; %> <c:choose> <c:when test="${a < 5}"> a is less than 5 </c:when> <c:when test="${a == 5}"> a is equal to 5 </c:when> <c:otherwise> a is greater than 5 </c:otherwise> </c:choose>
a is greater than 5