Hello Srikanth, How do we do preprocessing using Struts? This is what I'm looking for, from the action page we send back the result using ActionMapping.findForward("") this eventually renders a jsp page, but that jsp page requires some preprocessing like retrieving data or cleaning up somethings. How do we do that? Thanks, -Babu
Hi Babu, You should look at Struts Action Invocation Framework (SAIF) at struts.sourceforge.net It lets you configure a interceptor stack for every Action. Each interceptor has two methods - beforeAction and afterAction. They are invoked before and after the Action's execute() method. Hope this helps.
Isn't this the point of the Action class itself? The jsp (through a form or a link) calls an action to perform some process or select some data which is then either forwarded onto another Action or to a jsp.
use the requestprocessor if you want to do preprocessing. In the web.xml or struts.config you will find a requestprocessor class mentioned. Overwrite this one with your own (and change the config file) and then each request for an action does that pre-processing. on the internet / or in struts documentation search for requestprocessor. As usual this is not mentioned thoroughly in any of the books. So is it in this one ?
It seems like you guys are really complicating the initial question. It sounds to me like you have an action that currently forwards to a jsp page requiring cleanup or a data fetch. All you really need to go is make your action forward to another action (which will perform your preprocessing), and then that one can forward to your jsp page. JSP -- submit ---> ACTION --- findForward("preprocess")----> PREPROCESS_ACTION ---- findForward("success")-----> JSP