• 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

Struts 2: ObjectAware actions vs just pulling it out of the session scope

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I have a jsp that I want to have access to an object in my session map (let's say a user that is logged on) is it better to make a class whose only function is to be a "UserAware" action so that my interceptor can inject the User into it OR can I get away with just getting the user from the session scope in the jsp? Is one better than the other?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no "better", but that's what the "scope" interceptor is for, isn't it? (I've never really used it.) Otherwise there's a proliferation of interfaces that don't really do very much, and either a proliferation of interceptors, or a single interceptor that has to be updated, that has kind of lame functionality. If I don't have a general-purpose interceptor that does this automatically, and I'm not using Spring session-scoped beans, I'd just implement SessionAware and Preparable. YMMV, depending on your needs and application, though.
 
Pj Casaro
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks!
 
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic