• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

scope of bean declared in jsp:useBean

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,


<html>
<body>
<jsp:useBean id="address" class "AddressBean" />
<jsp:setProperty name="address" property="*" />
<jsp:include page="that.jsp" />
</body>
</html>

In this code, would "that.jsp" be able to access the bean "address" by jsp:getProperty without using useBean declaration?

This is a question from SCWCD kit and they say, if the scope was anything other than page, then that.jsp can access the bean "address" by declaring it using useBean and then by getProperty. But I run the code and see that even without useBean, that.jsp could access the "address" bean in this.jsp, when the scope is anything other than page.

So what should I conclude? I need your valuable opinion.

Thanks.
[ September 07, 2004: Message edited by: S Subramonyan ]
 
author
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because the first JSP has a useBean tag that does not specify the scope, then the PAGE scope is used. Therefore, only that page will have access to the attribute (and not "that.jsp"). If you had used any other scope, then it would be accessible.

HTH,
Bryan
 
Happily living in the valley of the dried frogs with a few tiny ads.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic