On Tue, 22 Jul 2003, Mark Chaimungkalanont wrote:

> Date: Tue, 22 Jul 2003 18:42:54 +1000
> From: Mark Chaimungkalanont <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Accessing the "servlet" property at Action instatiation time
>
> I'm trying to do some initialisation in my constructor. It calls other
> classes and tries to pass the class the Application context. However, at
> this stage, the "servlet" property has not been initialised in the Action
> yet. I assume it must be possible to get the ServletContext from somewhere,
> but I have no Idea where.
>
> Any help would be much appreciated.
>
> MyAction()
> {
>     super();
>     OtherClass.doStuff(servlet.getServletContext());
> }
>
> cheers
>

Action classes are instantiated in the usual way for JavaBeans -- the
zero-args constructor is used, THEN the property setters are called.  The
simplest solution, then, is to put your other-class stuff inside
setServlet() instead of in the constructor.  It will be called in a couple
of milliseconds.

> mc

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to