Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HFSJ chapter 5 doubt , Please help..

 
Vishal Chugh
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am confused about below : ( from chapter 5 of HFSJ)

Why we required ServletContextListner ( as we used for Dog example in book) if we could use dog as context attribute also ?
OR
Both will serve the same purpose ?

[for sure if we use it as context attribute , then it will have threading issue ], what other reasons could be?

Please help.

Thanks
Vishal Chugh
 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ServletContextListener - Use this listener when you want to get notifications for ServletContext Created and servlet context destroyed.

ServletContextAttributeListener - Use this listener when you want to get notifications for when any code adds/remove/replaces an attribute to servlet context via ServletContext.addAttribute() or ServletContext.removeAttribute()

Both are completely different. I will suggest you to try few examples and you will know the difference.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!