Easy Tutorial
❮ Jstl Function Split Jstl Format Message Tag ❯

<c:if> Tag

JSP Standard Tag Library

The <c:if> tag evaluates the value of an expression and executes its body content if the expression evaluates to true.

Syntax

&lt;c:if test="<boolean>" var="<string>" scope="<string>">
   ...
</c:if>

Attributes

The <c:if> tag has the following attributes:

Attribute Description Required Default Value
test Condition Yes None
var Variable to store the condition result No None
scope Scope of the var attribute No page

Example

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>c:if Tag Example</title>
</head>
<body>
&lt;c:set var="salary" scope="session" value="${2000*2}"/>
&lt;c:if test="${salary > 2000}">
   <p>My salary is: <c:out value="${salary}"/><p>
</c:if>
</body>
</html>
My salary is: 4000

JSP Standard Tag Library

❮ Jstl Function Split Jstl Format Message Tag ❯