Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to apply conditional operators in JSTL?

    • 0
    • 1
    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 834
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: