• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

page scope

 
Amru Jahagirdar
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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
Posts: 193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amru-

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.
http://www.coderanch.com/t/280935/JSP/java/JSTL-pageScope

Josh
 
Bindu Lakhanpal
Ranch Hand
Posts: 171
Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Josh & Bindu, thanks for the reply.. It helped me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic