Jsp Expression Language

JSP EL: It is a expression language which makes it easier for a programmer to fetch javabeans and various objects like request, session values on jsp. There are implicit objects also of EL. It simplifies the Presentation layer.

JSP EL starts with a "$" followed by a "{" and ends with a "}"

To use this we need to specify the isELIgnored attrbute of page directive.

  <%@ page isELIgnored ="true|false" %gt;

If it is true, EL expressions are ignored when they appear in static text or tag attributes. If it is false, EL expressions are evaluated by the container.

Simple example:


Basic EL Operators: There are many airthmetic,logical,relational and conditional operator which can be used in EL.

( ): For subexpression to change the evaluation order

+: Addition

-: Subtraction

*: Multiplication

/: or div Division

%: or mod Modulo (remainder)

==: or eq Equality

!=: or ne Inequality

<: or lt Less than

>: or gt Greater than

<=: or le Less than or equal

>=: or gt Greater than or equal

&&: or and Logical AND

||: or or Logical OR

!: or not Unary Boolean complement

EL implicit variable

pageScope: page scope variable

requestScope: request scope variables

sessionScope: session scope variables

e.g We have set one variable in session scope:


Fetching on another page usin EL

  ${ sessionScope.name }

applicationScope: application scope variables

param: Request parameters

  e.g <p>${param["name"]}</p>

paramValues: Request parameters as collections of strings

header: HTTP request headers

  e.g <h3>${header["user-agent"]}</h3>

headerValues: HTTP request headers as collections of strings

initParam : Context-initialization parameters

cookie : Cookie values

pageContext : PageContext object