Name
<c:if>
Synopsis
The <c:if>
action
evaluates its body only if the
specified expression evaluates to
true
. Alternatively, the evaluation result can be
saved as a scoped Boolean
variable.
Syntax 1: Without a body
<c:if test="booleanExpression
" var="var
" [scope="page|request|session|application"]/>
Syntax 1: With a body
<c:if test="booleanExpression
">JSP elements
</c:if>
Attributes
Attribute name |
Java type |
Dynamic value accepted |
Description |
---|---|---|---|
test |
boolean |
Yes |
The test expression |
var |
String |
No |
The variable name |
scope |
String |
No |
The variable scope |
Example
<c:if test=${empty param.empDate}"> <jsp:forward page="input.jsp"> <jsp:param name="msg" value="Missing the Employment Date" /> </jsp:forward> </c:if>
Get JavaServer Pages, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.