This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes what is HttpSessionBindingListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "what is HttpSessionBindingListener" Watch "what is HttpSessionBindingListener" New topic
Author

what is HttpSessionBindingListener

Roshini Sridharan
Ranch Hand

Joined: Jan 16, 2001
Posts: 143
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.

Regards
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hello,

SessionBinding Events are used to track the addition and deletion of Objects (attributes) from session.

Please refer following link for uses :

http://www.acknowledge.co.uk/java/tutorial/servlet_tutorial/servlets/working_sessions.html

Thanks


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Malli Raman
Ranch Hand

Joined: Nov 07, 2001
Posts: 312
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.

Regards


Hi Roshini,

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.
Roshini Sridharan
Ranch Hand

Joined: Jan 16, 2001
Posts: 143
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.

Regards
Roshini
Arul Prasad
Ranch Hand

Joined: Jan 20, 2005
Posts: 57
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.


Following is the sample code for JDBCQueryBean


web page


With Regards<br />Arul
Arul Prasad
Ranch Hand

Joined: Jan 20, 2005
Posts: 57
there is some concept of remote scripting u can see the sample page in the google lab

-->google Suggest


Remote scripting is used for call the remote methods without refreshing the page

for info

http://www.ashleyit.com/rs/main.htm
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by roshini sridhar:
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.

Regards
Roshini


In short, no.
Servlets sit and listen for a request and respond to it.
To get this kind of behaviour, you need your webpage to continuously poll the server for a statis change.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is HttpSessionBindingListener