Struts:Calling a Action Class from another Action class
Created Sep 3, 2002
James Page
This can be combined quite neatly with the standard security mechanism provided with Servlet/JSP applications - does depend a bit on which application server/web server vendor you are using! I think that the standard identifier in the request is 'j_target_url' - you could use the value of this session attribute to create an ActionForward in your SecurityAction class and forward the user to the original URL they requested - note that you will also have to authenticate the user with the web container as well!
You can easily forward between actions by specifiying the action as another forward in the struts configuration file:
<action path="/actions/firstAction"
type="example.SecurityAction"
scope="request">
<forward name="success"
path="/actions/secondAction.do"/>
<forward name="failure"
path="/pages/login.jsp"/>
</action>
<action path="/actions/secondAction"
type="example.BusinessAction"
scope="request">
<forward name="success" page="/pages/businessPage.jsp"/>
</action>
Alternatively, you can create an ActionForward object on the fly so that you could redirect the user to a protected URL request that has been stored in the session prior to going throught security.
Cheers
James