You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brian Hawkins <br...@gmail.com> on 2007/10/22 23:36:12 UTC

How to get initialized at startup

I'm pretty new to Struts2.

I have some code I need to initialize when the servlet comes up for the
first time.  How do I do that when I'm using struts and I do not have my own
servlet?  Do I create a servlet just for this purpose?

Thanks
Brian

Re: How to get initialized at startup

Posted by Piero Sartini <li...@pierosartini.de>.
> I have some code I need to initialize when the servlet comes up for the
> first time.  How do I do that when I'm using struts and I do not have my
> own servlet?  Do I create a servlet just for this purpose?

If you need something that is initialized when your webapp starts, I would 
suggest to write a ContextListener. For more information look at:
http://wiki.metawerx.net/wiki/ContextListener

Btw, in Struts 2 you do not use servlets but Actions.

	Piero

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to get initialized at startup

Posted by Brian Hawkins <br...@gmail.com>.
I did what Sartini suggested.  I implemented the ServletContextListener
interface and added it as a listener to my application.  I use it to create
and take down some database connections that I need for my application.  It
works really well.

Brian

On 10/24/07, vamsi <va...@gmail.com> wrote:
>
> I am writing my own servlet for this as I didn't found anything.
> As I feel I have more control on that.
> post it if you got solution for this one.
> ----- Original Message -----
> From: "Brian Hawkins" <br...@gmail.com>
> To: <us...@struts.apache.org>
> Sent: Tuesday, October 23, 2007 3:06 AM
> Subject: How to get initialized at startup
>
>
> > I'm pretty new to Struts2.
> >
> > I have some code I need to initialize when the servlet comes up for the
> > first time.  How do I do that when I'm using struts and I do not have my
> > own
> > servlet?  Do I create a servlet just for this purpose?
> >
> > Thanks
> > Brian
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: How to get initialized at startup

Posted by vamsi <va...@gmail.com>.
I am writing my own servlet for this as I didn't found anything.
As I feel I have more control on that.
post it if you got solution for this one.
----- Original Message ----- 
From: "Brian Hawkins" <br...@gmail.com>
To: <us...@struts.apache.org>
Sent: Tuesday, October 23, 2007 3:06 AM
Subject: How to get initialized at startup


> I'm pretty new to Struts2.
>
> I have some code I need to initialize when the servlet comes up for the
> first time.  How do I do that when I'm using struts and I do not have my 
> own
> servlet?  Do I create a servlet just for this purpose?
>
> Thanks
> Brian
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org