Expression Language ( EL ) pageScope, requestScope, sessionScope, and applicationScope

Expression Language implicit objects      

                                                                           

EL contains 11 implicit objects.
The power of EL is just because of these implicit objects only.
The following is the list of all EL implicit objects.

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

                              1.The Scope Objects:
The pageScope, requestScope, sessionScope, and applicationScope implicit objects are used to retrieve data from request, session,page,application scopes.

Ex:1  To access the value of session scoped attribute ‘x’  ${sessionScope.x}
It prints the value of request scoped attribute ‘x’
If there is no such type of attribute we will get blank space ${requestScope.x}

Ex:2    ${x}
Jsp container first checks in page scope for the attribute x .if it is available it prints attribute  value.  If it is not available then it will check in request scope followed by session and application scope.  It simply acts aspageContext.findAttribute(String name);  method.

Test.jsp

 <%@ page isELIgnored="false" %>
 <%
      pageContext.setAttribute ("x", 100);
      pageContext.setAttribute ("y", 1000);
      pageContext.setAttribute ("X", 10);
 %>
 <h2> Attribute  "x" value in scope : ${x}</h2> <br>
<h2>Attribute "x" in request scope : ${requestScope.x} </h2><br>
<h2>Attribute "y" in session scope : ${sessionScope.y}</h2> <br>
 <h2>Attribute 'y' value : ${y}</h2>

OutPut:


                                                                              



Thanks For Making This Possible! Kindly Bookmark and Share it.

Technorati Digg This Stumble Stumble Facebook Twitter

No comments:

Post a Comment