Are session and sessionScope the same in JSP EL?

The ActionContext is a Struts2 thing, and it's created in every request that is handled by the framework. When it's created the framework populates it along with the servlet stuff with it's own implementations of request, session, and applicaton. And where you using it in the application these objects are referenced. To access the servlet stuff use the ServletActionContext that helps to retrieve the appropriate resources. Struts2 also wraps the ServletRequest to provide access to the action properties and valueStack from the EL expressions. sessionScope, requestScope, and applicationScope used with EL expressions to evaluate to the servlet stuff attributes. That are the differences.


  1. session, request, application are the actually HttpSession,HttpServletRequest and ServletContext objects while sessionScope, requestScope and applicationScope provide access to all the session, request and application scoped attributes.

You can say that applicationScope > sessionScope > requestScope.

  • applicationScope attributes will be accessible to all the sessions, all the requests across the web applications. These attributes stay alive as long as application is alive
  • sessionScope attributes will be accessible to all the requests across the current HttpSession. These attributes stay alive as long as session is alive
  • requestScope attributes will be accessible from the current request only. Once the response is completed, they are gone.

With expression language (EL), the scope items are value maps of attributes in the objects that they refer to. For instance, the requestScope is a map representation of values in the request object. This is explained in pretty clear detail on this page: Java Servlet and JSP. If you read through the EL sections, you'll notice a point about request vs request scope here: The requestScope is NOT request object.

I would recommend reading through this page to get a better understanding of servlet/jsp in general.

As far as how the ActionContext relates to these items, it is really a wrapper used by struts to encapsulate the servlet. You can read more specifics about it here: Accessing application, session, request objects.

There have been some references to implicit values given here, but I feel like just saying it's implicit doesn't really explain much. When you are using EL to access servlet variables, you can explicitly declare which scope you want to reference, such as:

 ${requestScope.myVariable}

You can also reference it implicitly by omitting the scope:

 ${myVariable}

Now, the problem that can arise here is that variables with the same name can cause collision. EL will check implicit values in a specific order: pageScope, requestScope, sessionScope, and applicationScope, param, paramValues, header, headervalues, initParam, cookie, pageContext. What this means is that if you have a variable in the request scope with the same name as a variable in session or application scope for instance, the request scoped value will be referenced.


By default page, request, session and application scope objects are available to JSP pages. So you can access then using EL syntax.

And following table shows IMPLICIT objects available to EL.

       Implicit object            Description
1.     pageScope        Scoped variables from page scope
2.     requestScope     Scoped variables from request scope
3.     sessionScope     Scoped variables from session scope
4.     applicationScope Scoped variables from application scope
5.     param            Request parameters as strings
6.     paramValues      Request parameters as collections of strings
7.     header           HTTP request headers as strings
8.     headerValues     HTTP request headers as collections of strings
9.     initParam        Context-initialization parameters
10.    cookie           Cookie values
11.    pageContext      The JSP PageContext object for the current page

So session and sessionScope are same but differs in context they are used.More specifically session is object and sessionScope is map (key, value) of Attribute and its value.

  • If you say ${session.sessionAttr} it refers to session object available to JSP page.
  • If you say ${sessionScope.sessionAttr} it refers to IMPLICIT session object available to EL.
  • Or if you just say ${attrName} it will search attrName in all scope from page to application scope.