It's not a secret anymore!*
The moose likes Struts and the fly likes Struts 2: ObjectAware actions vs just pulling it out of the session scope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2: ObjectAware actions vs just pulling it out of the session scope" Watch "Struts 2: ObjectAware actions vs just pulling it out of the session scope" New topic
Author

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

Pj Casaro
Ranch Hand

Joined: Jul 13, 2010
Posts: 47
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?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Jul 13, 2010
Posts: 47
thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 2: ObjectAware actions vs just pulling it out of the session scope
 
Similar Threads
what does java.io.serializable do ???
Request ActionForm validate
Connection Pool with JSPs
session - approach ?
problem while keeping scope as session