In JSP file sometimes we need to put conditional operators through JSTL.
Example: In the below example I am applying && and || operators.
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<html>
<head>
<title>Demo</title>
</head>
<body>
<h1>Demo for Operators</h1>
<c:set var="age" value="12"/>
Your age is <c:out value="${age}"/>
<br/>
<c:if test="${(age >= 10) && (guess <= 20)}">
<b>Age is in range</b><br/>
</c:if>
<c:if test="${(age < 10) || (guess > 20)}">
<b>Not in range...</b><br/>
</c:if>
</body>
</html>
Hope this will help you :)
0 Comment(s)