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.
Struts 2 question huh....this could get confusing since Struts 1.x and Struts 2 are so different. I played around a little with WebWork. My understanding is that you would store properties that are accessed by your JSP as properties of your action class. WebWork (and Struts 2) has a concept called a Value Stack. It is a little hard to explain and I don't fully understand how it works (magic?) but your Action class is placed on the top of the value stack where its properties can be seen by your JSP page.
If you search around the web for phrases like "WebWork Value Stack" I am sure you can find out more information. Since I don't get the feeling that many people on this forum are using Struts 2 (I am not), you might have to stick around and educate the rest of us.