|
How to work with ServletContextAttributeListener |
|
|
This J2EE tip describes the use of ServletContextAttributeListener in servlets.
ServletContextAttributeListener is an abstract base class for listeners
that receive notification when attributes change on a given ServletContext.
import javax.servlet.ServletContext;
import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributesListener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class MyServletContextAttributeListener
implements ServletContextAttributesListener {
/* This method is invoked when an attribute is added
to the ServletContext object
*/
public void attributeAdded (ServletContextAttributeEvent scab)
{
System.out.println("An attribute was added to the " +
"ServletContext object");
}
/* This method is invoked when an attribute is removed
from the ServletContext object
*/
public void attributeRemoved (ServletContextAttributeEvent scab)
{
System.out.println("An attribute was removed from " +
"the ServletContext object");
}
/* This method is invoked when an attribute is replaced
in the ServletContext object
*/
public void attributeReplaced (ServletContextAttributeEvent scab)
{
System.out.println("An attribute was replaced in the " +
"ServletContext object");
}
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.