• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

what is HttpSessionBindingListener

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic