Two Laptop Bag*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "ServletContextAttributeListener doesn Watch "ServletContextAttributeListener doesn New topic
Author

ServletContextAttributeListener doesn't receive attributeRemoved() notification

Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 347

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: 47
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: 347

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

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

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://aspose.com/file-tools
 
subject: ServletContextAttributeListener doesn't receive attributeRemoved() notification
 
Similar Threads
cannot find symbol : ServletContextListner
PrintWriter after log()
ServletContext AttributeListener again
Problem invoking a servlet directly from FireFox browser
ServletContext AttributeListener problem