0% found this document useful (0 votes)
2 views2 pages

JSP EL Lecture Notes

JSP Expression Language (EL) simplifies data access in JSP pages by allowing the use of a cleaner syntax without Java code. It supports various scopes for attribute resolution and provides operators and common objects for handling data. EL enhances code readability and maintainability, making it easier to work with dynamic content in web applications.

Uploaded by

ေမဇင္
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

JSP EL Lecture Notes

JSP Expression Language (EL) simplifies data access in JSP pages by allowing the use of a cleaner syntax without Java code. It supports various scopes for attribute resolution and provides operators and common objects for handling data. EL enhances code readability and maintainability, making it easier to work with dynamic content in web applications.

Uploaded by

ေမဇင္
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

JSP Expression Language (EL) – Lecture Notes

Expression Language (EL) in JSP is used to simplify the access to data stored in JavaBeans
components, request/session/application attributes, and more without using Java code in
the JSP page.

1. Syntax:
Basic format: ${variableName}

2. Why Use EL?


- Shorter and cleaner syntax than scriptlets

- Easy access to attributes in different scopes

- Improves code readability and maintainability

3. Scope Resolution Order:


When you write ${name}, EL searches for 'name' in the following scopes:

1. Page Scope

2. Request Scope

3. Session Scope

4. Application Scope

4. Example of Setting and Using EL:

// In Servlet
request.setAttribute("username", "May Zin Htun");

// In JSP
Welcome, ${username}!

5. Using Operators in EL:


Arithmetic: ${mark + 10}, ${price * quantity}

Relational: ${mark >= 40}, ${age < 18}

Logical: ${passed && excellent}, ${!failed}

6. Common EL Objects:
param: ${param.name} (Form parameter)
paramValues: ${paramValues.name} (Multiple form values)

header: ${header['User-Agent']} (HTTP headers)

cookie: ${cookie.sessionID.value} (Cookies)

initParam: ${initParam.configName} (Context params)

7. EL Functions (with JSTL):


Example: ${fn:length(name)} returns length of the name string

Expression Language helps you write cleaner, simpler JSP pages. Practice using EL in your
form handling and dynamic display pages. ❤️

You might also like