<% // Check if attribute has been set Object o = pageContext.getAttribute("com.mycompany.name1", PageContext.PAGE_SCOPE); if (o == null) { out.println("'com.mycompany.name1' is not 'null'"); } // Save data pageContext.setAttribute("com.mycompany.name0", "value0"); // PAGE_SCOPE is the default pageContext.setAttribute("com.mycompany.name1", "value1", PageContext.PAGE_SCOPE); pageContext.setAttribute("com.mycompany.name2", "value2", PageContext.REQUEST_SCOPE); pageContext.setAttribute("com.mycompany.name3", "value3", PageContext.SESSION_SCOPE); pageContext.setAttribute("com.mycompany.name4", "value4", PageContext.APPLICATION_SCOPE); out.println("
"); out.println("
"); out.println("SHOWING VALUES OF ATTRIBUTE :-"); %>
<%-- Show the values --%> <%= pageContext.getAttribute("com.mycompany.name0") %> <%-- PAGE_SCOPE --%>
<%= pageContext.getAttribute("com.mycompany.name1", PageContext.PAGE_SCOPE) %>
<%= pageContext.getAttribute("com.mycompany.name2", PageContext.REQUEST_SCOPE) %>
<%= pageContext.getAttribute("com.mycompany.name3", PageContext.SESSION_SCOPE) %>
<%= pageContext.getAttribute("com.mycompany.name4", PageContext.APPLICATION_SCOPE) %>