application

Beans with application scope are accessible within pages processing requests that are in the same application space as the page in which they were created. References to the object will be released when the runtime environment reclaims the ServletContext. More simply put, this means that, until the JSP engine is restarted, the bean created with application scope will be available. Beans with application scope are best used when you need to share information between JSPs and servlets for the life of your application.

To give an example of application scope, we are going to use two JSPs. The first will load the Counter bean using an id of counter and a scope of application. It will then print out the current value of the Counter bean, ...

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.