This week's giveaways are in the MongoDB and Jobs Discussion forums.
We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line!
See this thread and this one for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes ServletContextAttributeListener doesn't receive attributeRemoved() notification Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "ServletContextAttributeListener doesn Watch "ServletContextAttributeListener doesn New topic
Author

ServletContextAttributeListener doesn't receive attributeRemoved() notification

Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 334

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

Joined: Sep 17, 2011
Posts: 34
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

Joined: Aug 31, 2006
Posts: 334

Thanks a lot lot Niraj! I overlooked the compilation error. How silly!
Niiraj Patel
Ranch Hand

Joined: Sep 17, 2011
Posts: 34
Faisal,

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

Please manually compile and deploy classes.

Regards,
Niraj
Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 334

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!
 
I agree. Here's the link: http://jrebel.com/download
 
subject: ServletContextAttributeListener doesn't receive attributeRemoved() notification
 
Similar Threads
ServletContext AttributeListener problem
ServletContext AttributeListener again
Problem invoking a servlet directly from FireFox browser
cannot find symbol : ServletContextListner
PrintWriter after log()