Forums Register Login

bean in or out scope?

+Pie Number of slices to send: Send
My code below






what i had expected below,

default
new

the jsp page responded below,

new
default

Why?


+Pie Number of slices to send: Send
I think I understand why,

at the time the <jsp:setProperty name="b" property="p" value="new"/> is executed, there exist two beans named b. One in request scope the other in session scope.

setProperty tag does not accept scope attribute so it starts to search through all scopes starting with page scope, then request scope and so on. It sets the property of the first bean found.

In your example it sets the "new" value to the bean in the request scope so the bean in session scope is left uninitialized.

[ January 08, 2007: Message edited by: Jasiek Motyka ]
[ January 09, 2007: Message edited by: Jasiek Motyka ]
+Pie Number of slices to send: Send
Thanks Jasiek

i also tried out myself, in short,

- set/getAttribute methods: always scoped
- jsp:useBean: always scoped
- jsp:set/getProperty: scope order from request, session and likewards
- EL bean without scope prefix, scope order from request, session and likewards
- EL bean with scope prefix, always scoped
+Pie Number of slices to send: Send
 

jsp:set/getProperty: scope order from request, session and likewards



Can anyone tell the complete search order
+Pie Number of slices to send: Send
Scopes are searched from the narrowest to the widest. From page scope, request scope, session scope to the application scope.
Clowns were never meant to be THAT big! We must destroy it 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 917 times.
Similar Threads
jsp:useBean Vs importing class file and using new
Bean standard action doubt
Doubt in jsp:useBean attribute 'type'
problem on c:set
Help: Wrox Profession SCWCD - don't understand
More...

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