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?
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.
Joined: Jul 13, 2010
subject: Struts 2: ObjectAware actions vs just pulling it out of the session scope