This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is HttpSessionBindingListener

 
Roshini Sridharan
Ranch Hand
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 951
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Malli Raman
Ranch Hand
Posts: 312
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Arul Prasad
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic