Nearby lessons
12 of 30JSP - EL Introduction
📌 What You Will Learn
- Understand why EL was introduced
- Write basic EL expressions
- Compare EL syntax with standard JSP syntax
Expression Language (EL) is a language designed to eliminate Java code from JSP pages. It provides a简洁 syntax for accessing request parameters, attributes, and beans using the ${} notation.
What is EL?
The main objective of EL is to eliminate Java code from JSPs. In general, we use EL with JSTL and Custom Tags for complete elimination of Java code.
EL vs Standard Syntax
| Task | Standard JSP Syntax | EL Syntax |
|---|---|---|
| Print request parameter "user" | <%= request.getParameter("user") %> | ${param.user} |
| Print attribute "x" | <%= pageContext.findAttribute("x") %> | ${x} |
EL Suppresses Null
- Standard syntax prints "null" for missing attributes
- EL prints blank (nothing) for missing attributes
This makes EL much safer — no ugly "null" strings in your output.
EL Syntax Rules
- Any variable used in EL must be an attribute in some scope (page, request, session, or application)
- EL expressions are enclosed in
${...} - The container evaluates the expression and writes the result to the response
📝 Key Takeaways
- EL eliminates Java code from JSPs
- EL syntax: ${expression}
- EL suppresses null — prints blank instead
- EL variables must be attributes in some scope
🧠 Test Your Knowledge
3 QuestionsProgress: 0 / 3