trainingtrains Logo

91-9990449935

 0120-4256464

Expression Language (EL) in JSP

The Expression Language (EL) simplifies the accessibility of data stored in the Java Bean component, and other objects like request, session, application etc.

There are many implicit objects, operators and reserve words in EL.

It is the newly added feature in JSP technology version 2.0.


Syntax for Expression Language (EL)

Implicit Objects in Expression Language (EL)

There are many implicit objects in the Expression Language. They are as follows:

Implicit ObjectsUsage
pageScopeit maps the given attribute name with the value set in the page scope
requestScopeit maps the given attribute name with the value set in the request scope
sessionScopeit maps the given attribute name with the value set in the session scope
applicationScopeit maps the given attribute name with the value set in the application scope
paramit maps the request parameter to the single value
paramValuesit maps the request parameter to an array of values
headerit maps the request header name to the single value
headerValuesit maps the request header name to an array of values
cookieit maps the given cookie name to the cookie value
initParamit maps the initialization parameter
pageContextit provides access to many objects request, session etc.

Simple example of Expression Language that prints the name of the user

In this example, we have created two files index.jsp and process.jsp. The index.jsp file gets input from the user and sends the request to the process.jsp which in turn prints the name of the user using EL.

index.jsp

process.jsp


Example of Expression Language that prints the value set in the session scope

In this example, we printing the data stored in the session scope using EL. For this purpose, we have used sessionScope object.

index.jsp

process.jsp


Precedence of Operators in EL

There are many operators that have been provided in the Expression Language. Their precedence are as follows:

[] .
()
-(unary) not ! empty
* / div % mod
+ - (binary)
< <= > >= lt le gt ge
== != eq ne
&& and
|| or
?:

Reserve words in EL

There are many reserve words in the Expression Language. They are as follows:

ltlegtge
eqnetruefalse
andornotinstanceof
divmodemptynull
Next TopicMVC In Jsp