This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JavaBean Scope in JSP pages  RSS feed

 
Reema Patel
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a bit confused as to why the following code snippet is compiling and working.




The bean reference "store" is local to the if block. This should have resulted in a compilation error. Instead, everything works just fine. I'm using Tomcat 5.


- Reema
[ December 16, 2006: Message edited by: Reema Patel ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Reema Patel:

The bean reference "store" is local to the if block.


Not.

The scripting variable created by the useBean action is indeed limited to the block. But that's not what you are referencing in the getProperty action. That is referencing the scoped variable created by useBean. And that has page scope.
[ December 16, 2006: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. Confusing semantics such as this is just one of the many reasons that scriplets are discouraged in the JSP 2.0 environment.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!