This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Servlets and the fly likes ServletContextListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "ServletContextListener" Watch "ServletContextListener" New topic
Author

ServletContextListener

Saurabh Saha
Ranch Hand

Joined: Dec 08, 2004
Posts: 52
Hi All,
Please tell me what is ServletContextListener and where we use it. I know some little about it that we use this to add attribute on the context, so that all the servlets of this context can access this attribute, but it not so much clear to me, please clear my doubt.

Thanks,
Vivek
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

As it's name suggests, a context listener is an object that sits and listens for the startup and shutdown of a context.

It's a nice way to preform initialization before any servlets get instanciated and cleanup after they are destroyed.

http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContextListener.html


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
jQuery in Action, 2nd edition
 
subject: ServletContextListener