Bean Scope

Beans in JSP applications always have a clearly defined scope which determines the context in which they are available. There are four scopes, listed here in order of "size" (largest first):

application

Beans with application scope are always available within an application.

session

Beans with session scope are available for the duration of a particular user's application session. Sessions normally expire after an application-defined period of inactivity. Use of session scope should be avoided in Escenic applications.

request

Beans with request scope are available within all the JSP files involved in responding to a particular HTTP request.

page

Beans with page scope are only available within a single JSP file. When a JSP file contains a call to another JSP file, any page scope beans created in the calling file are not available in the called file.

The current application, session, request and page are represented internally in JSP by Java objects called implicit objects because they are always available. Any application-created beans are stored as special properties of these objects called attributes. The scope of an application bean is determined by which of these implicit objects it belongs to.