Presented below is an example that shows how to use PageContext in JSP.

Java Code:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%
  synchronized (pageContext) {
    Class thisClass = getClass();
    pageContext.setAttribute("thisClass", thisClass, PageContext.PAGE_SCOPE);
    System.out.println("Stored reference");

    Class theClass = (Class) pageContext.getAttribute("thisClass", 
    PageContext.PAGE_SCOPE);
    System.out.println("The retrieved reference is " + theClass);
  }
%>

<html>
  <body>
    The class that instantiated this JSP is 
     <c:out value="${pageScope.thisClass.name}" />.
  </body>
</html>