File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

HttpSessionBindingListener database synchronization confusion

Peter Piddle

Joined: Jun 13, 2012
Posts: 26

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?

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

Joined: Apr 07, 2010
Posts: 2092

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.

I agree. Here's the link:
subject: HttpSessionBindingListener database synchronization confusion
It's not a secret anymore!