It's not a secret anymore!*
The moose likes Servlets and the fly likes Listener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Listener" Watch "Listener" New topic
Author

Listener

vasu maj
Ranch Hand

Joined: Jul 12, 2001
Posts: 395
This application is running on Tomcat 4.0.4. Servlet is set up to start when the server is started. There is a listener class entry which listens on connectionpooling class. Problem is this is getting closed first and then when Servlet is getting closed it was trying to do some meintenece on database and finding that there are no connections available and is giving errors. IS there away to change the order of things so the servlet is closed first and then the conection pool?


Thanks,

vasu


What a wonderful world!
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Yes, you'll want to read up on ServletContextListeners:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContextListener.html

They were introduced in Servlet Spec 2.3 (which TC4 impliments).


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
vasu maj
Ranch Hand

Joined: Jul 12, 2001
Posts: 395
I didn't get you
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

My point is to open and close your pool from the events in the contextListener, not a servlet. The contextInitialized event gets fired before the servlets get loaded. Visa versa for the closing.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Listener