struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Chisholm" <David_Chish...@i2.com>
Subject RE: Does struts provide hooks for app-specific initialization?
Date Wed, 21 Jun 2000 13:07:03 GMT
Thanks for both suggestions.  This is probably how I'll implement it except
that I will likely override the ActionServlet.process(req, resp) method
instead of processActionInstance() because I need to override the processing
at the highest level.
Thanks again,
David


> -----Original Message-----
> From: jhut@inst.strykercorp.com [mailto:jhut@inst.strykercorp.com]
> Sent: Wednesday, June 21, 2000 7:24 AM
> To: struts-user@jakarta.apache.org
> Subject: Re: Does struts provide hooks for app-specific initialization?
>
>
> On Tue, 20 Jun 2000, David Chisholm wrote:
>
> > 1.  App-specific initialization
> >
> > Is there anyplace in struts where I can add a hook to perform
> application
> > specific initialization when the struts action servlet is
> loaded?  If not,
> > is there some other recommended method of doing this?
>
> The Struts ActionServlet has a couple of convenient places to plug in you
> custom behavior.  For custom application initialization you can extend
> ActionServlet like this:
>
> public class MyActionServlet
>     extends org.apache.struts.action.ActionServlet {
>
>     protected void initApplication() throws ServletException {
>         super.initApplication();
>         // do application-specific initialization
>     }
> }
>
>
> > 2.  Request pre-processing
> >
> > Is there a central point in struts where I can examine and modify all
> > requests before they are delegated to an Action?
>
> Same method as above, but do application-specific action before allowing
> the action to be processed:
>
> public class MyActionServlet
>     extends org.apache.struts.action.ActionServlet {
>
>     protected void processActionInstance(ActionMapping mapping,
>                                          ActionForm formInstance,
>                                          HttpServletRequest request,
>                                          HttpServletResponse response)
>         throws IOException, ServletException {
>
>         // do application-specific action
>
>         super.processActionInstance(mapping, formInstance,
>                                     request, response);
>         }
>
> }
>
> You could also choose to make the above servlets final, as well.
>
> Hope this helps,
>
> -jh
>
> --
> Jeff Hutchison <jhut@inst.strykercorp.com>
> Stryker Instruments, Kalamazoo, MI
>


Mime
View raw message