JSTL If Example

JSTL If Example explains about How to use JSTL If tag in JSP for testing the conditions.

Consider an example where you need to check whether the given conditions is correct or not

JSTL If is using for evaluating a condition, which tests if the available condition is true.

It optionally exposes a Boolean scripting variable representing the outcome of this condition. Using 'c:if', you can test with conditions whether it is correct or not

you can see the below example demonstrating JSTL If function which is evaluating for a condition

Required Libraries

You need to download

  1. Tomcat 9
  2. JSTL 1.2

Following jar must be in classpath

  1. jstl-1.2.jar

JSTL If Example

// JSTL c:if Example

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

    request.setAttribute("student", "rockey");

<title>JSTL If Example</title>


<c:if test="${student == 'rockey' }">Hi Rockey!<br /></c:if>
<c:if test="true">Hello world!</c:if>

Hi Rockey!
Hello world!


1 Responses to "JSTL If Example"
  1. Rockey 2012-01-20 08:23:45.0

Your email address will not be published. Required fields are marked *