Scope of the JSP objects
Scope of a JSP object determines whether that is object is available to be used at a particular place in the application or not. There are four types of scopes available for JSP objects. These are:-
- application - an object having this scope will be available to all the JSP pages belonging to the same web application. Example: implicit object 'application' has this scope.
- session - an object having this scope will be available for all the JSP pages belonging to the same session in which this object was instantiated. Example: implicit object 'session' has this scope.
- request - an object having this scope will be available to all the pages which are involved in serving the same request. Example: implicit object 'request' has this scope.
- page - an object having this scope will be available only on that particular JSP page where it was instantiated. This is the default scope for any object created from within a JSP page and most of the implicit objects have this scope only including 'page', 'out', 'exception', 'config', 'pageContext', and 'response'. Read more about implicit objects in the article - Implicit Objects in JSP >>
We can easily figure out that the 'page' scope is the least visible and the 'application' scope is the most visible among all the scopes available for JSP objects ( page < request < session < application in terms of Visibility).