Java.Servlet.Name the implicit, internal JSP EL objects and how they differ from JSP objects.

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 ObjectDescription
pageScopeMap of variables in page scope
requestScopeMap of variables in request scope
sessionScopeMap of variables in session scope
applicationScopeMap of variables in application scope
paramMap of request parameters (single value per key)
paramValuesMap of request parameters (array of values per key)
headerMap of HTTP request headers (single value per key)
headerValuesMap of HTTP request headers (array of values per key)
cookieMap of cookies by cookie name
initParamMap of context init parameters from web.xml
pageContextThe actual PageContext object

🧠 Key Differences from Classic JSP Implicit Objects

AspectClassic JSP Implicit ObjectsEL Implicit Objects
TypeJava Objects (HttpServletRequest, HttpSession, etc.)Map-like objects for easy access
Access StyleJava code: session.getAttribute("user")EL syntax: ${sessionScope.user}
PurposeFull programmatic control (read/write, method calls)Read values easily in a simple, clean way
VisibilityAvailable inside Java blocks <% %>Available inside ${...} expressions
Error HandlingYou must null-check manuallyEL handles nulls gracefully (empty string)
FunctionalityMuch 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:
    pageScoperequestScopesessionScopeapplicationScope.
  • So ${user} will find user no matter where it is (starting from the nearest scope).

🎯 Quick Final Table

FeatureClassic JSPEL
ObjectReal Java ObjectsMap-like objects
Example accesssession.getAttribute("name")${sessionScope.name}
Null handlingMust check manuallyHandled automatically
Readability for designersLow (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).
This entry was posted in Без рубрики. Bookmark the permalink.