[go: up one dir, main page]

0% found this document useful (0 votes)
8 views3 pages

Expression Language

java expression language

Uploaded by

john.dow.1024.05
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Expression Language

java expression language

Uploaded by

john.dow.1024.05
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

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)

1. ${ expression }

Implicit Objects in Expression Language (EL)


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

Implicit Objects Usage

pageScope it maps the given attribute name with the value set in the page scope

requestScope it maps the given attribute name with the value set in the request scope

sessionScope it maps the given attribute name with the value set in the session scope

applicationScope it maps the given attribute name with the value set in the application scope

param it maps the request parameter to the single value

paramValues it maps the request parameter to an array of values

header it maps the request header name to the single value

headerValues it maps the request header name to an array of values

cookie it maps the given cookie name to the cookie value

initParam it maps the initialization parameter

pageContext it provides access to many objects request, session etc.


EL param example
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
1. <form action="process.jsp">
2. Enter Name:<input type="text" name="name" /><br/><br/>
3. <input type="submit" value="go"/>
4. </form>
process.jsp
1. Welcome, ${ param.name }

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

index.jsp
1. <h3>welcome to index page</h3>
2. <%
3. session.setAttribute("user","sonoo");
4. %>
5.
6. <a href="process.jsp">visit</a>
process.jsp
1. Value is ${ sessionScope.user }

EL cookie example
index.jsp
1. <h1>First JSP</h1>
2. <%
3. Cookie ck=new Cookie("name","abhishek");
4. response.addCookie(ck);
5. %>
6. <a href="process.jsp">click</a>
process.jsp
1. Hello, ${cookie.name.value}

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:
lt le gt ge

eq ne true false

and or not instanceof

div mod empty null

Next TopicMVC In Jsp

You might also like