• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

scope resolution in JSP

 
Anant Kadiyala
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone explain the difference between 'page scope' and 'request scope'? In this book I am reading it says, " The request scope is for objects that need to be available to all pages processing the same request".
I am confused by this statement. Lets say I have page A that has a 'Next' button that takes me to page B. Similarly the 'Next' on page B takes me to page C and so on.. Now, isn't the request made to the web server different from Next on page A to that of the Next on page B?! If that is true, how can we have the "same request" for multiple pages?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page scope is the smallest, an object in page scope can't be seen if you forward the request. It has nothing to do with your example of HTML pages, it refers to a JSP page.
An object in request scope only lives during a single request - response cycle.
Bill
------------------
author of:
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you set a page-scope attribute and then forward the request, the attribute will not be visible to the forwarded page. If you set a request-scope attribute, it will be visible to the forwarded page. I believe pages included via jsp:include work the same way, but I'm not 100% sure.
 
John Juneja
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That helps!! Thanks a lot :-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic