FileDocCategorySizeDatePackage
SessionAttribListen.javaAPI DocExample2135Wed Feb 11 14:31:40 GMT 2004com.jspservletcookbook

SessionAttribListen

public class SessionAttribListen extends Object implements HttpSessionAttributeListener

Fields Summary
Constructors Summary
public SessionAttribListen()
Creates new SessionAttribListen

        
        System.out.println(getClass().getName());
    
Methods Summary
public voidattributeAdded(javax.servlet.http.HttpSessionBindingEvent se)

       
        HttpSession session = se.getSession();
        String id = session.getId();
        String name = se.getName();
        String value = (String) se.getValue();
        String source = se.getSource().getClass().getName();
        String message = new StringBuffer(
         "Attribute bound to session in ").append(source).
           append("\nThe attribute name: ").append(name).
             append("\n").append("The attribute value:").
               append(value).append("\n").
                 append("The session ID: ").
                   append(id).toString();
        System.out.println(message);
   
public voidattributeRemoved(javax.servlet.http.HttpSessionBindingEvent se)

         
         HttpSession session = se.getSession();
         String id = session.getId();
         String name = se.getName();
         if(name == null)
             name = "Unknown";
         String value = (String) se.getValue();
         String source = se.getSource().getClass().getName();
         String message = new StringBuffer(
           "Attribute unbound from session in ").append(source).
              append("\nThe attribute name: ").append(name).
                append("\n").append("The attribute value: ").
                  append(value).append("\n").append(
                    "The session ID: ").append(id).toString();
         System.out.println(message);
   
public voidattributeReplaced(javax.servlet.http.HttpSessionBindingEvent se)

         
          String source = se.getSource().getClass().getName();
          String message = new StringBuffer(
            "Attribute replaced in session  ").
              append(source).toString();
          System.out.println(message);