JSTL If Example

Keywords : JSTL If, JSTL If Example, JSTL If Tag Example, JSTL c:if tag 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 JSTL tag ('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

Tools Needed For This Example

You need to download

  1. Tomcat 7
  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");
%>

<html>
<head>
<title>JSTL If Example</title>
</head>

<body>

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

</body>
</html>
Output
Hi Rockey!
Hello world!



JSTL If JSTL If Example JSTL If Tag Example JSTL c:if tag Example

Comments (1)
16.05.2012 04:13:58 Rockey
Thanks for the article