You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andreas Schildbach <an...@bch-fms.de> on 2001/07/06 19:01:39 UTC
Where to do the init() for Actions?
Is there a similar thing to Servlet.init() in Actions?
I want to access EJB's in Actions and have to setup the InitialContext, look
up some Bean Remote Interfaces, etc. I don't want to do this every time my
Action is called.
If I were using a plain Servlet, I would put this stuff into init()...
Thanks,
- Andreas
Re: Where to do the init() for Actions?
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Sat, 7 Jul 2001, Martin Cooper wrote:
> You can override the setServlet() method to do this. That method is called
> with a non-null value when an instance is being created and initialised, and
> then called again with a null value when the instance is about to be cleaned
> up.
>
This is the right answer, but I want to add one little warning -- be
*sure* that you call the superclass method!
public void setServlet(ActionServlet servlet) {
super.setServlet(servlet);
... your custom initialization ...
}
> --
> Martin Cooper
>
Craig
>
> ----- Original Message -----
> From: "Andreas Schildbach" <an...@bch-fms.de>
> To: <st...@jakarta.apache.org>
> Sent: Friday, July 06, 2001 10:01 AM
> Subject: Where to do the init() for Actions?
>
>
> > Is there a similar thing to Servlet.init() in Actions?
> > I want to access EJB's in Actions and have to setup the InitialContext,
> look
> > up some Bean Remote Interfaces, etc. I don't want to do this every time my
> > Action is called.
> > If I were using a plain Servlet, I would put this stuff into init()...
> >
> > Thanks,
> >
> > - Andreas
> >
> >
> >
>
>
>
Re: Where to do the init() for Actions?
Posted by Martin Cooper <ma...@tumbleweed.com>.
You can override the setServlet() method to do this. That method is called
with a non-null value when an instance is being created and initialised, and
then called again with a null value when the instance is about to be cleaned
up.
--
Martin Cooper
----- Original Message -----
From: "Andreas Schildbach" <an...@bch-fms.de>
To: <st...@jakarta.apache.org>
Sent: Friday, July 06, 2001 10:01 AM
Subject: Where to do the init() for Actions?
> Is there a similar thing to Servlet.init() in Actions?
> I want to access EJB's in Actions and have to setup the InitialContext,
look
> up some Bean Remote Interfaces, etc. I don't want to do this every time my
> Action is called.
> If I were using a plain Servlet, I would put this stuff into init()...
>
> Thanks,
>
> - Andreas
>
>
>
RE: Where to do the init() for Actions?
Posted by Niall Pemberton <ni...@btInternet.com>.
ActionServlet is a "plain Servlet" you can extend it and override the init()
method (make sure you call super.init(), so that the standard Struts init(0
stuff is done.
Niall
> -----Original Message-----
> From: Andreas Schildbach [mailto:andreas.schildbach@bch-fms.de]
> Sent: 06 July 2001 18:02
> To: struts-user@jakarta.apache.org
> Subject: Where to do the init() for Actions?
>
>
> Is there a similar thing to Servlet.init() in Actions?
> I want to access EJB's in Actions and have to setup the
> InitialContext, look
> up some Bean Remote Interfaces, etc. I don't want to do this every time my
> Action is called.
> If I were using a plain Servlet, I would put this stuff into init()...
>
> Thanks,
>
> - Andreas
>
>