• Post Reply Bookmark Topic Watch Topic
  • New Topic

HttpSessionAttributeListener

 
Jay Damon
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it not possible to have the HttpSessionAttributeListener notify a specific instance of a class? I have a client who has literally dozens of user attributes in the session object and I am attempting to unify these attributes in a single user object maintained in the session to simplify both retrieval and maintenance. I created a user class but then discovered I had to provide a no-argument constructor because the server instantiates a new instance each time this listener fires. I solved the instance issue by checking for an instance of the class in the session and setting the values on it as opposed to the instance the server creates. The specific instance needs to be notified of attribute changes because I am unable to change all classes in the application that update the session attributes at once. My solution works. I am just wondering if my approach is correct. Comments please...
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try HttpSessionBindingListener instead. Make to classes. One implementing HttpSessionBindingListener with empty binding/unbinding methods. One extending that class, overriding the binding/unbinding methods, and doing something in it. Make the instance you wish to be notified a class of the second type.


[ February 13, 2007: Message edited by: Satou kurinosuke ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!