I understand the concept of request scope, session scope & application scope.
However I am not clear about the page scope(and page context also..). Can somebody please explain with an example?
My understanding is that page scope is the immediate page in which an attribute is set. If the user is forwarded to another page the attribute will not be passed along with the request, with the session or available via the application. It's just for the life of a single page.
In another post, Shawn Bayern described a use case. If you have a variable in the context of a scriptlet and you want it to be accessible within a JSP tag, then you can set the variable as an attribute in the pageContext and the JSP tag will be able to access it from there.
Objects set in page scope are accessible in a translation unit in which they are defined. i.e they exist in a single translation unit and only for processing of a single request.These objects are maintained as attribute value pairs by an instance of a concrete subclass of the abstract class PageContext.(in jsp this instance is available as implicit object pageContext).
The only way for actions(Standard JSP actions and custom tags) to share data and JavaBean objects with other actions appearing in the same JSP page (translation unit) and in same request is to use the pageContext and page Scope.
Joined: Sep 16, 2009
Josh & Bindu, thanks for the reply.. It helped me.