Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Page scope and request scope

 
satish pune
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,
Could someone explain the difference between the two scopes : page and request
Is there any specific place where we should use page scope ?
What are the advantages / disadvantages of page scope ?
Thanks in advance ,
-satish
 
Owee Nicolas
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Satish,
If you are using the two scopes with regards to instantiating a JavaBean within a JSP using the jsp:UseBean tag, the page scope means that the JavaBean is available from the current page. This is the default.
The request scope means the JavaBean is available from the current page's request object using the getAttribute method. This reference is discarded upon completion of the current client request.
The advantage of using the page scope is that the JavaBean is only instantiated on that particular page. This is useful for short operations and those that does not require object persistance.
Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic