This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Lifecycle of Servlet Context

 
Hue Cheng
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ServletContext get destroyed as soon as the Web Server shuts down..
hth
MB
 
Hue Cheng
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
Then do you mean lifetime of a servlet context = lifetime of servlet?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic