<%@ page import="java.util.*" %> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/ea/core" %> JSTL: EcmaScript EL Support -- Comparison Operator Example

Comparison Operators

The Comparison operators compare values for equality and identity and return a boolean value depending on the result of the comparison. Numbers, strings, and boolean values are compared by value. Objects, arrays, and functions are compared by reference.

Here are some examples:

<% request.setAttribute("myString", new String("Harrison Ford")); %> <% request.setAttribute("a", new Integer(4)); %> <% request.setAttribute("b", new Integer(7)); %> <% request.setAttribute("c", new Integer(0)); %>

Operator: == (Equality)

Operation Result
==
==

Operator: != (Inequality)

Operation Result
!=
!=

Operator: === (Identity)

Operation Result
===
===

Operator: !== (Non-Identity)

Operation Result
!==
!==

Operator: < (Less Than)

Operation Result
<

Operator: > (Greater Than)

Operation Result
>

Operator: <= (Less Than or Equal)

Operation Result
<=

Operator: >= (Greater Than or Equal)

Operation Result
>=