aspose file tools*
The moose likes JSP and the fly likes HttpSessionBindingListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "HttpSessionBindingListener" Watch "HttpSessionBindingListener" New topic
Author

HttpSessionBindingListener

Purusottam Mohanty
Greenhorn

Joined: Aug 03, 2006
Posts: 3
An object X implement's a HttpSessionBindingListener.
The valueBound method is to print "B" and the valueUnbound method is to
print "U".

The code to be executed is :

session.setAttribute("A", new X());
session.setAttribute("A", new X());
session.removeAttribute("A");

What should be output:

1.BBU 2.BUBU or 3.BBUU

and why ?

all responses are appreciated.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61196
    
  66

What would your answer be. And why?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Purusottam Mohanty
Greenhorn

Joined: Aug 03, 2006
Posts: 3
I would prefer to go for BUBU as it seems more logical.
The first instance is bound to the sesssion for key "A" : 'B'
To bound the second instance to the session for the same key "A"
It has to unbound the first one : 'U'
and then bound the second instance: 'B'
and finally unbound the second instance : 'U' so answer should be: BUBU

but I ran a program for it and the output was : BBUU ..... am not sure of
how and why that happens.

Thanks for your reply
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HttpSessionBindingListener