JSTL - jstl core if
<prefix:if> ये tag दिए गया expression language(EL) अगर true होता है इस tag का body content display होता है |
<prefix:if> tag और <prefix:when> tag ये दोनों एक जैसे होते है | लेकिन <prefix:when> tag ये <prefix:choose> tag का child tag होता है |
Syntax for <prefix:if> in JSTL
<prefix:if test="${expression}"> -------- </prefix:if>
<prefix:if> Attribute in JSTL
test : यहाँ पर expression language का इस्तेमाल किया जाता है |
Example for <prefix:if> Tag in JSTL
Source Code :Output :<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c:set var="a" value="10"/> <c:if test="${a < 20}"> Yes, a is less than 20 </c:if> <c:choose> <c:when test="${a < 20}"> Yes, a is less than 20 </c:when> </c:choose>
Yes, a is less than 20 Yes, a is less than 20