• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session Listener Question

 
priya kulkarni
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have the following code snippet. The session attribute listener prints messages like "attribute added","attribute removed","attribute replaced" for the corresponding event to the standard output.

Now when the request parameter is "replace" then it prints "attribute added followed by "attribute removed" followed by "attribute replaced" ..

Can anyone please explain why the "atribute removed" is being printed.
String attributeEvent = req.getParameter("sessionBinding");
if(attributeEvent.equalsIgnoreCase("add"))
{
session.setAttribute("IceCream",myIceCream1);
}
else if(attributeEvent.equalsIgnoreCase("remove"))
{
session.setAttribute("IceCream",myIceCream1);
session.removeAttribute("IceCream");
}
else if(attributeEvent.equalsIgnoreCase("replace"))
{
session.setAttribute("IceCream",myIceCream1);
session.setAttribute("IceCream",myIceCream2);
}
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you also post your listener ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic