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

ServletContextAttributeListener doesn't receive attributeRemoved() notification

 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've the following ServletContextAttributeListener:


And here is my servlet:


The last line of doGet() removes an attribute. But, MyContextAttributeListener is not notified about this event. Why?
 
Niiraj Patel
Ranch Hand
Posts: 47
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Faisal Ahmad wrote:The last line of doGet() removes an attribute. But, MyContextAttributeListener is not notified about this event. Why?


It has a Typo mistake. Notice the getSerlvetContext instead of getServletContext.

your last line of doGet is :



It should be :



You should get compilation error for this.

Regards,
Niraj
 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot lot Niraj! I overlooked the compilation error. How silly!
 
Niiraj Patel
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Faisal,

While preparing for exam, the best practice is the Notepad.

Please manually compile and deploy classes.

Regards,
Niraj
 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you are right. I use a better notepad - TextPad. However, I am using a batch script (make.bat) that I wrote exclusively for practicing exercises. Unfortunately, it lacks the mechanism to stop upon compilation error. I just overlooked the error. I'll have to modify the script.

Thanks again!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic