shutdown hook for java web application

Use a class that implements ServletContextListener in your web.xml:

<web-app>
    <!-- Usual stuff here -->
    <listener>
        <listener-class>com.mycompany.MyClass</listener-class>
    </listener>
</web-app>

Leave a Comment