Forums Register Login

<jsp:useBean Body Execution Doubt

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
I child proofed my house but they still get in. Distract them with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 883 times.
Similar Threads
Reason for change of scope from request to page
jsp:useBean doubt
jsp:usebean | NoClassDefFoundError
jsp:useBean
JSP and JavaBeans
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 05:47:54.