Examples of EL Expressions
Java Platform, Enterprise Edition (Java EE) 8
The Java EE Tutorial

Previous Next Contents

Examples of EL Expressions

Table 9-1 contains example EL expressions and the result of evaluating them.

Table 9-1 Example Expressions

EL Expression

Result

${1> (4/2)}

false

${4.0>= 3}

true

${100.0 == 100}

true

${(10*10) ne 100}

false

${'a' > 'b'}

false

${'hip' lt 'hit'}

true

${4> 3}

true

${1.2E4 + 1.4}

12001.4

${3 div 4}

0.75

${10 mod 4}

2

${((x, y) → x + y)(3, 5.5)}

8.5

[1,2,3,4].stream().sum()

10

[1,3,5,2].stream().sorted().toList()

[1, 2, 3, 5]

${!empty param.Add}

False if the request parameter named Add is null or an empty string

${pageContext.request.contextPath}

The context path

${sessionScope.cart.numberOfItems}

The value of the numberOfItems property of the session-scoped attribute named cart

${param['mycom.productId']}

The value of the request parameter named mycom.productId

${header["host"]}

The host

${departments[deptName]}

The value of the entry named deptName in the departments map

${requestScope['javax.servlet.forward.servlet_path']}

The value of the request-scoped attribute named javax.servlet.forward.servlet_path

#{customer.lName}

Gets the value of the property lName from the customer bean during an initial request; sets the value of lName during a postback

#{customer.calcTotal}

The return value of the method calcTotal of the customer bean


Previous Next Contents
Oracle Logo  Copyright © 2017, Oracle and/or its affiliates. All rights reserved.