File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes page scope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "page scope" Watch "page scope" New topic

page scope

Amru Jahagirdar
Ranch Hand

Joined: Sep 16, 2009
Posts: 39
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?
Thank you...........
Joshua Smith
Ranch Hand

Joined: Aug 22, 2005
Posts: 193

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.


Rational Pi Blog - Java, SCJP, Dev Bits-
Bindu Lakhanpal
Ranch Hand

Joined: Oct 17, 2008
Posts: 171

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.

Amru Jahagirdar
Ranch Hand

Joined: Sep 16, 2009
Posts: 39
Josh & Bindu, thanks for the reply.. It helped me.
I agree. Here's the link:
subject: page scope
It's not a secret anymore!