aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HttpSessionBindingListener database synchronization confusion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HttpSessionBindingListener database synchronization confusion" Watch "HttpSessionBindingListener database synchronization confusion" New topic
Author

HttpSessionBindingListener database synchronization confusion

Peter Piddle
Greenhorn

Joined: Jun 13, 2012
Posts: 26

Hi,
I am reading Head First JSP and Servlets and preparing for the exam. It says in topic of HttpSessionBindingListener, that its valueBound() and valueUnBound() can be used when we need to synchronize with the database. I am not aware much about entities with respect to databases. But that is what i get that let say we can make Dog class an Entity and make it implement HttpSessionBindingListener. But still i am unable to understand when we say when it is added to session and it is removed, how valueBound() and valueUnBound() can help synchonize with the database. Are these methods where we will be doing database CRUD operations?
Thanks,


Peter Piddle - Skype(peter.piddle)
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1716
    
  25

Hi Peter,

Did you read the explanation in chapter 5 on page 183?

When to synchronize your objects with the database is always a question of web-design. Do you want to update every change to the database or do you want postpone and update a batch of changes.

Are these methods where we will be doing database CRUD operations?

You could do a read in the valueBound() and an update in the valueUnBound() method as an example.

Regards,
Frits
 
wood burning stoves
 
subject: HttpSessionBindingListener database synchronization confusion