Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

HttpSessionAttributeListener getAttribute vs getValue

Hi,

I am reading about  HttpSessionAttributeListener as follows


attributeAdded method called when a new attribute name is first added to a session.
attributeReplaced method called when a new value is assigned to an existing name. attributeAdded is not called in this case.
To obtain old value use event.getValue and to obtain new value is use session.getAttribute.

In my ListenerDemo class  method I only see getValue() but do not see getAttribute()

      public void attributeAdded(ServletContextAttributeEvent arg0) {
            System.out.println("Attribute Added");
            System.out.println("old"+arg0.getValue()); (i wasable to see getAttribute on arg0)


                      System.out.println("new"+arg0.getAttribute()); (not able to see getAttribute on arg0???)

      }






I wonder what it mean by old value and new value and why we need to get old value.


when and why we use HttpSessionAttributeListener in practical applications.

Please advise.

Any links resources ideas highly appreciated. Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial