• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

<jsp:useBean Body Execution Doubt

 
Sai Surya
Ranch Hand
Posts: 463
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

Please take a look at the following code.





Since jsp use bean doesn't have a body, the jsp should not set the name property to the bean.
It just have to create an empty bean. However, when I run the code, I am surprised to see that
the name attribute has been set by calling Foo.setName().

Is my understanding wrong?
 
Sai Surya
Ranch Hand
Posts: 463
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry! I understood how it works after re-reading the section in HFSJ.

<jsp:setProperty always sets value if outside ><jsp:useBean. If inside ><jsp:useBean ...></jsp:useBean> the body invocation is conditional dependeng on whether bean exists in any of the scopes.
 
Niteen Patil
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you are correct. The body of the bean is executed conditionally.If the bean object doesn't exist the bean will be created in the given scope and the body is executed.
If the bean exists in the given scope the body will not be executed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic