See javax.servlet.ServletContextListener. The contextStarted() event
method is the first thing your application will ever see, and that is the
right place to put initialization of things that need to go into servlet
context attributes for all filters and servlets to see.
Application event listeners are registered in web.xml like this:
<listener>
<listener-class>com.mycompany.mypackage.MyListenerClass</listener-class>
</listener>
Craig
On 17 Dec 2001, Dr. Evil wrote:
> Date: 17 Dec 2001 02:10:22 -0000
> From: Dr. Evil <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Startup order
>
>
> I'm using Tomcat with both filters and servlets. Here's the problem:
> I need to load a few objects into the servlet context (a logger, a DB
> connection pool, etc), which will be used by all the other filters and
> servlets. Here's the problem: The Init method of some of the filters
> need some of these objects, and it looks like Tomcat runs the
> load-on-startup servlets after it has called all the init methods of
> all the filters.
>
> What's the right way for me to make objects available in the filters'
> init methods? Should I create a filter, with no mapping, and do all
> my object loading in that filter's init method? How can I make sure
> that that filter's init method is called before any of the other
> filters? Do filters init in the order they appear in the web.xml
> file?
>
> Thanks for any tips on this.
>
> --
> To unsubscribe: <mailto:[EMAIL PROTECTED]>
> For additional commands: <mailto:[EMAIL PROTECTED]>
> Troubles with the list: <mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>