How can Struts check for a set of global conditions before processing an action?
Created May 7, 2012
This often comes up in the context of authenticating users or with other control flow issues.
The direct approach would be to subclass the ActionServlet controller servlet, and override a method like processActionPerform (which actually calls the selected Action) or processActionForward (which forwards control to the returned logical page name). You could then inspect the current state of the world, and inject flow-of-control changes like this still utilizing the superclass's basic functionality.
If, as part of injecting control follow changes, you need to track where the user was in your application, you might have your ActionServlet subclass maintain a request-scope attribute with a well-known name, containing the value returned by request.getServletPath(). This would act something like the "referer" header in an HTTP request, and provide some history tracking.