This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpSessionBindingListener database synchronization confusion

 
Peter Piddle
Greenhorn
Posts: 26
IntelliJ IDE jQuery Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2276
81
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic