• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

page and request scope of bean

 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
what is the page and request scope for a JavaBean included in JSP file? i understand session and application scopes well.
here is what i understand about page and request scopes.
page : it means whenever we come on the same JSP page the bean is visible (accessible or whatever we want to call it).
request: the bean is visible to all the pages visited from the page where the bean has been declared first time. tho this is not a "deep" operation in the sense that if i've bean B on page P.jsp declared as of request scope and if i have page P1.jsp 's link on the page the B is visible on page P1.jsp as well but if i've another link P2.jsp on page P1.jsp then on P2.jsp the B bean is not visible.
am i right?
regards
maulin.
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A bean created with "page"(default) scope is available only in the page it is created.
As for "request" scope, the bean B created in p.jsp is available (i.e. can be referenced) in all the subsequent forwarded pages as long as "request" is passed to them ONLY for the current request.
-Srini
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Srini,
if u can answer addressing my thinking which i wrote down in the question it would help me more.
i guess as per your answer my argument of request scope is not right. but i will need more clarification on this from you. i don't think i understood what you want to say exactly as far as the request scope is concerned. e.g. what did you want to say by passed to them ONLY for the current request.?
please bare with me. i'm slow at gaining things!
regards
maulin.
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Think of it this way - when a user sends a request, it is NOT necessary that this response to that request be generated in the one servlet or JSP. It can span more than one JSP page, right! Now that you know that your request will be going from one page to the other, you should recognize that its the same request and you are trying to generate a response.
When you instantiate a Bean on the request scope, then this bean is available in all the JSP pages that you send this req object to.
Actually, if you play with the code that I suggested in your useBean post, you should be able to clear this doubt also.
Let me know if you need a different explanation...
- satya
[ February 09, 2002: Message edited by: Madhav Lakkapragada ]
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
all right satya,
so if i use sth like jsp:forward then that will comply to what u r suggesting here. i got what u wanted to convey. now i am clear about it (don't worry i wont write 'm clear until i'm so YES i'm clear).
regards
maulin.
 
Srini Admala
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks satya for explaining what I meant.
-Srini
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Srini for your help.
regards
maulin
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic