File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes about ServletContextListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "about ServletContextListener" Watch "about ServletContextListener" New topic
Author

about ServletContextListener

Raj Ohadi
Ranch Hand

Joined: Jun 30, 2006
Posts: 316
we have contextDestroyed contextInitialized in ServletContextListener. Now questions are --

a) when server is restarted, contextInitialized will be called; when server is shut down, contextDestroyed is called, right ?
b) when web application is redeployed, both contextDestroyed and contextInitialized will be called, right ? (old one is destroyed and new one is initiated)
c) wehn web app is undeployed, contextDestroyed is called, right ?

any other scenario that may cause either one to be called ?

thanks
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

It sounds like you've got it.

A very easy way to test your assumptions would be to put a System.out.println statement in both of your methods and watch your logs as you start, stop, and restart your application.

If you're lucky enough to be working on a Unix box, tail -f <filename> will allow you to follow your log file as you are hitting your app. If you're on Windows some text editors (Textpad is one) have settings to automatically refresh the window if the file is updated.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: about ServletContextListener