Logical Operator in JSP Expression Language

What are the JSP Expression Language Logical Operators?

Explanation

JSP Expression Language Logical operators are used with two operands that returns either a "true" or "false" value.
Logic Expression Result
And ${true and true} true
And ${true && false} false
Or ${true or true} true
Or ${true || false} true
Not ${not true} false
Not ${!false} true

Example :


<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<h5>Not Operator</h5>
<c:if test="$!{3>1}" var="b" />
The result of using NOT operator with (3>1) is: ${b}
Result :

Not Operator
The result of using NOT operator with (3>1) is: false

In the above example we have use "!" operator, used with a expression "3>1" which is "true". Since the "!" operator is used it becomes "false", this boolean value is stored in a variable "boo" and displayed.

Ask Questions

Ask Question