application

The application object holds a reference to the javax.servlet.ServletContext retrieved from the servlet configuration. The following code snippet, from the JSP's generated servlet, shows how the application object is initialized:

pageContext = _jspxFactory.getPageContext(this, request, response,
  "errorpage.jsp", true, 8192, true);

application = pageContext.getServletContext();

You can see that the generated servlet simply gets a reference to the current ServletContext and stores it in the application object. The application object has application scope, which means that it is available to all JSPs until the JSP engine is shut down.

The application object is most often used to access environment information. One of the more common ...

Get Pure Java Server Pages™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.