import javax.servlet.*;
import java.io.*;
import java.util.*;
public class ServletEventListener implements ServletContextListener, ServletContextAttributeListener, ServletRequestListener
{	
   ServletContext contx;
   String name;	
   String value;
   public void contextInitialized(ServletContextEvent ce)
   {
      contx=ce.getServletContext();
      contx.log("Context has been initialized at " + new Date());
   }
   public void contextDestroyed(ServletContextEvent ce)
   {
      contx.log("Context has been destroyed at " + new Date());		
   }
   public  void attributeAdded(ServletContextAttributeEvent srae)
   {
      name=srae.getName();
      value=(String)srae.getValue();
      contx.log("An attribute with name: "  + name + " and value: " + value  + " has been added to the context at: " + new Date());	
   }
   public  void attributeRemoved(ServletContextAttributeEvent srae)
   {
      contx.log("Attribute with name: "  + name + " and value: " + value  + " has been removed from the context at: " + new Date());	
   }
   public  void attributeReplaced(ServletContextAttributeEvent srae)
   {
      contx.log("Attribute with name: "  + name + " and value: " + value  + " has been replaced context at: " + new Date());
   }
   public void requestInitialized(ServletRequestEvent e)
   {
      contx.log("A request has been initialized at: " + new Date());
   }
   public void requestDestroyed(ServletRequestEvent e)
   {
      contx.log("A request has been destroyed at: " + new Date());
   }
}
