• Post Reply Bookmark Topic Watch Topic
  • New Topic

scope of bean declared in jsp:useBean

 
S Subramonyan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • 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 ]
 
Bryan Basham
author
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • 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
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!