aspose file tools*
The moose likes Servlets and the fly likes Intercepting TomCat 5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Intercepting TomCat 5" Watch "Intercepting TomCat 5" New topic
Author

Intercepting TomCat 5

Yuma Shankar
Greenhorn

Joined: Jun 07, 2005
Posts: 24
We have a development environment running TomCat (within Eclipse).

We use a connection pool. And everytime we build our app, the context reloads and if we have any existing connections at that point, they do not get cleared up or reused. So, the only way to clear them up right now is to restart TomCat.

As a work around, I was looking into implementing a Context Interceptor where I could put the connection clean up code in the context reload method. I find that TomCat 3 had a BaseInterceptor class in org.apache.tomcat.core. But, I cannot find any Interceptor classes to extend in TomCat5.

Any ideas?

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

Have you checked into using a context listener?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Try a google search for ServletContextListener.
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContextListener.html


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

[klunk]


While you're at it, you might want to look into container managed connection pooling. This should lift a lot of these types of troubles from your shoulders.
Yuma Shankar
Greenhorn

Joined: Jun 07, 2005
Posts: 24
Thanks a lot. I will look into both the options suggested-the listener and making the connection pooling container based.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Intercepting TomCat 5