aspose file tools
The moose likes Servlets and the fly likes HttpSessionBindingListener and Session.setAttribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpSessionBindingListener and Session.setAttribute" Watch "HttpSessionBindingListener and Session.setAttribute" New topic

HttpSessionBindingListener and Session.setAttribute

Zkr Ryz
Ranch Hand

Joined: Jan 04, 2001
Posts: 187
Hello all.
I have a doubt about HttpSessionBindingListener
and session.setAttribute( name, attrib )

The API says

In the implementation I have a log message to see if the method get called

I've wrote a message in the constructor as well to see when a new Object is created.
The first time I call the servlet through the POST method the messages appear in the console, but If I do refresh valueBound message does not appears even though the constructor message does ( by the way the servlet get called within a form and when I do refresh the Browser ask if I want to re-send the data and I click ok ;P )

This means that a new Object is created and setted on the session with the same name, according with the API the session should replace the existing attribute with the new one Im I right ???
Is this behavior the correct ?

By the way , the session calls hashCode and equals on the existing object when the new one is tryed to be set on the session and IMHO as the object is the same ( according with hashCode and equals() ) the session refuses to replace it thus valueBound and valueUnbound are never called.

Im using WebLogic Server 6.1 and I don't know if this issue is related only to that version but as I want my aplication to be portable and be usable in other app servers I would like to hear if someone knows if this should be the correct behavior or is exclusive to WLS

Thank you kn advance.
[ December 30, 2002: Message edited by: Zkr Ryz ]
[ December 30, 2002: Message edited by: Zkr Ryz ]
I agree. Here's the link:
subject: HttpSessionBindingListener and Session.setAttribute