This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Lifecycle of Servlet Context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Lifecycle of Servlet Context" Watch "Lifecycle of Servlet Context" New topic
Author

Lifecycle of Servlet Context

Hue Cheng
Greenhorn

Joined: Aug 15, 2003
Posts: 8
What is the lifecycle of a servlet context?
Would its lifetime be exactly the same as servlet?
I'm wondering when and how the methods
ContectInitialized and ContextDestroyed of
ServletContextListener will be called,
would anyone please explain them to me?
Thank you!
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
ServletContext get destroyed as soon as the Web Server shuts down..
hth
MB


Malhar Barai
SOA & Java Book
Hue Cheng
Greenhorn

Joined: Aug 15, 2003
Posts: 8
Thank you.
Then do you mean lifetime of a servlet context = lifetime of servlet?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
I think the Servlet Context exists outside the lifetime of a servlet since there may be many servlets sharing a context in a single "web application." Read the JavaDocs for the javax.servlet.ServletContext interface for the authoritative information.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Lifecycle of Servlet Context
 
Similar Threads
calling servlets from normal java class
Managing lifecycle of servlets
ServletContextListener and jspInit
Servlet Object
JTA Transaction on Stateful Session Bean.