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

ServletContextListener

 
Saurabh Saha
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic