struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Don Brown" <>
Subject Re: Struts 2 and passing data using interceptors
Date Thu, 30 Nov 2006 22:29:59 GMT
If you only need request-scoped data, you don't need to bother with
the ScopeInterceptor or even the ServletRequestAware interface.
Simply define a getter on your action that returns the object in
question, then access it via your JSP via JSP EL (JSP 2.0), a JSTL
expression, or a Struts 2 property tag.


On 11/30/06, fahlen <> wrote:
> Hi. I'm new to Struts and have a question regarding how data is passed from
> an Action (in Struts 2) to the JSP which one is redirected to after the
> action is executed. Reading the documentation on Struts 2, I've found that
> using the Scope Interceptor one can specify Action properties to be bound to
> the session or application scope. This is configured in struts.xml with the
> <interceptor-ref name="scope"> tag and then setting the appropriate
> parameters. See
> Now, say I access an EJB from an Action. The method of the EJB returns some
> data. Is it good programming practice (in Struts) to store this data in the
> session object, later to be accessed from a JSP? This should allow me to
> pass the data, but perhaps there is some other alternative which is
> preferred. Storing information in the session object would maybe be good
> practice for data such as user id, contents of a shopping cart, etc. The
> scope I believe I am interested in is request scope, since the data returned
> from the invoked EJB method is data from an search, only to be
> used in the JSP displayed immediately after the execution of the Action.
> Would the preferred method in my case then be to implement the
> ServletRequestAware interface in the Action and store data of interest in
> the request object? I can't find any interceptor that does this. I'm sure
> one can create user defined interceptors, but if there's a standard method
> for this functionality provided by the framework, then I guess that would be
> the preferred way to go.
> I'm grateful for any input on the matter. Cheers.
> --
> View this message in context:
> Sent from the Struts - User mailing list archive at
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message