This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Ron Miller wrote:when is servlet context created? and when is it destoryed? is init() called before or after servlet context created?
The ServletContext is available for all servlets / jsp's in your web application. So it is created before the init() method in Servlet is called. It's life time is pretty much the life time of the web application. ServletConfig is also created before init() method and passed in as a parameter to init(ServletConfig config) method.
You can create a class implements ServletContextListener and override contextInitialized(), contextDestroyed() methods. Add
in web.xml. See for yourself when is context initialized and destroyed.