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
http://www.twdata.org/backups/WW/scope-interceptor.html 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 Amazon.com 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.