• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

bean in or out scope?

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My code below






what i had expected below,

default
new

the jsp page responded below,

new
default

Why?


 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Bob CHOI
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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



Can anyone tell the complete search order
 
Stary Kapec
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Scopes are searched from the narrowest to the widest. From page scope, request scope, session scope to the application scope.
reply
    Bookmark Topic Watch Topic
  • New Topic