This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Originally posted by roshini sridhar: Can anybody provide with some sample code that works deals with javax.servlet.http.HttpSessionBindingListener and Event classes and a bit of idea where its helpful.
SessionBindingListener is used to notify the objects, which is going to bound with the session or unbound from the session.
If you are using going to include the customer object in the session, then session.put() method will indirectly invoke the customer (object's valueBound method) which implements this SessionBindingListerner. Similarly while removing customer object from the session, the valueUnbound() method is called.
Basically this listeners are used to notify the object to perform some operation before joining to /after coming out from session scope.
Joined: Jan 16, 2001
Thanks to both for the reply. I would like to know whether there is any way to push the servlet content automatically when some event happens.
Eg: In case of chat if any message is there for the user received in the DB, how do make it visible to the user other than constant refresh of the Page.
hi The standard javax.servlet.http package provides the HttpSessionBindingListener interface and HttpSessionBindingEvent class to manage session-scoped resources. A JSP page must appropriately manage resources acquired during its execution, such as JDBC connection, statement, and result set objects. for example, acquire a database cursor when the bean is instantiated and close it when the HTTP session is terminated.
An object that implements the HttpSessionBindingListener interface can implement a valueBound() method and a valueUnbound() method, each of which takes an HttpSessionBindingEvent instance as input.
These methods are called by the servlet container--the valueBound() method when the object is stored in the session; the valueUnbound() method when the object is removed from the session or when the session times-out or becomes invalid.