Scopes an object can have in a JSP page

Explain the different scopes an object can have in a JSP page.

The scope of JSP objects is divided into four parts. They are:

1. Page: Page scope means the object can be accessed within the page only on which it is created. The data is valid only during the processing of the current response; once the response is sent back to the browser, the data is no longer valid. If the request is forwarded to another page or the browser makes another request as a result of a redirect, the data is also lost.

2. Request: The object with request scope means they can be accessed by any page that serves same request. Once the container has processed the request, the data is released. Even if the request is forwarded to another page, the data is still available though not if a redirect is required.

3. Session: This scope means, the JSP object is accessible from pages that belong to the same session from where it was created. For example, when users log in, their username could be stored in the session and displayed on every page they access. This data lasts until they leave the Web site or log out.

4. Application: A JSP object created using the ‘application’ scope can be accessed from any pages across the application. Application scope variables are typically created and populated when an application starts and then used as read-only for the rest of the application.
Use of Externalization interface
Externalization is same as serialization. It extends Serializable interface. To externalize your object, you need to implement Externalizable interface that extends ...
Widening conversion and Narrowing conversion
For a primitive data types, a value narrower data type can be converted to a value of a broader data type without loss of information...
How do we implement deep cloning?
Deep cloning makes a distinct copy of each of object’s field. By this the two objects are not dependent on each other...
Post your comment