Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to put if/else condition in JSTL?

    • 0
    • 1
    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 389
    Comment on it

    Sometimes we need to show HTML based on some conditions, so for this we use JSTl in JSP file.

    Example: In the below code I'm changinf heading based on condition.

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    
    <html>
    <head>
    <title>Demo</title>
    </head>
    <body>
    <c:choose>
        <c:when test="${(apiKey != null && apiKey != '')}">
            <h2> Public Map</h2>
        </c:when>    
        <c:otherwise>
          <h2> My Locations</h2>
        </c:otherwise>
      </c:choose>
    
    </body>
    </html>
    

    Hopr 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: