Sun Java System Web Server 7.0 Developer's Guide to Java Web Applications

Overriding Destroy

Override the class destructor destroy() to write log messages or to release resources that have been opened in the servlet's cycle. Resources should be appropriately closed and de-referenced so that they are recycled or garbage collected. The destroy() method runs just before the servlet itself is deallocated from memory. For more information, see the servlet API specification.

For example, the destroy() method could write a log message like the following example, based on the example for Overriding init():


out.println("myServlet was accessed " + thisMany " times.\\n");