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

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "HttpSessionBindingListener" Watch "HttpSessionBindingListener" New topic


Purusottam Mohanty

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());

What should be output:

1.BBU 2.BUBU or 3.BBUU

and why ?

all responses are appreciated.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60046

What would your answer be. And why?

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

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
subject: HttpSessionBindingListener
Similar Threads
que 22 and 55 in HFS final mock
What's the difference between HttpSessionAttributeListener and HttpSessionBinding...
Doubt in HFSJ Mock Exam Question 55
notification not as expected from session binding listener