When you use EL (${...}) in JSP, there are special implicit objects available automatically inside the EL context.
✅ These are different from the classic JSP implicit objects (request, response, session, etc.) you use in Java code inside JSP.
🔵 List of Implicit Objects in JSP EL
| EL Implicit Object | Description |
|---|---|
pageScope | Map of variables in page scope |
requestScope | Map of variables in request scope |
sessionScope | Map of variables in session scope |
applicationScope | Map of variables in application scope |
param | Map of request parameters (single value per key) |
paramValues | Map of request parameters (array of values per key) |
header | Map of HTTP request headers (single value per key) |
headerValues | Map of HTTP request headers (array of values per key) |
cookie | Map of cookies by cookie name |
initParam | Map of context init parameters from web.xml |
pageContext | The actual PageContext object |
🧠 Key Differences from Classic JSP Implicit Objects
| Aspect | Classic JSP Implicit Objects | EL Implicit Objects |
|---|---|---|
| Type | Java Objects (HttpServletRequest, HttpSession, etc.) | Map-like objects for easy access |
| Access Style | Java code: session.getAttribute("user") | EL syntax: ${sessionScope.user} |
| Purpose | Full programmatic control (read/write, method calls) | Read values easily in a simple, clean way |
| Visibility | Available inside Java blocks <% %> | Available inside ${...} expressions |
| Error Handling | You must null-check manually | EL handles nulls gracefully (empty string) |
| Functionality | Much broader (can call methods) | Mainly for attribute/property access |
🔥 Example Using EL Implicit Objects
1. Access Request Parameter
${param.username}
Equivalent to:
request.getParameter("username");
Access Request Scope Attribute
${requestScope.product}
Equivalent to:
request.getAttribute("product");
Access Session Attribute
${sessionScope.user.name}
Equivalent to:
User user = (User) session.getAttribute("user");
String name = user.getName();
Access Application Context Init Parameter
${initParam.appName}
Equivalent to:
application.getInitParameter("appName");
📢 Important Notes:
- If you don’t specify scope, EL searches automatically through the scopes in order:
pageScope→requestScope→sessionScope→applicationScope. - So
${user}will finduserno matter where it is (starting from the nearest scope).
🎯 Quick Final Table
| Feature | Classic JSP | EL |
|---|---|---|
| Object | Real Java Objects | Map-like objects |
| Example access | session.getAttribute("name") | ${sessionScope.name} |
| Null handling | Must check manually | Handled automatically |
| Readability for designers | Low (needs Java knowledge) | High (no Java needed) |
🚀 Summary
- JSP Implicit Objects are for programming (with Java code).
- EL Implicit Objects are for viewing and displaying data easily (with
${...}expressions).