I'm using Tomcat 7.0.42. Most examples of ServletContext.addFilter() and ServletContext.addServlet() show it being used from a contextInitialized() event handler, however, the Servlet 3.0 spec doesn't limit the use of addServlet/addFilter to contextInitialized() (unless it is in there somewhere and I missed it).
I have successfully used addServlet() from the init() method of a Servlet (e.g. I've dynamically created several servlets from a servlet that I specify in a web.xml), however, I have not successfully been able to use addFilter() from my Servlet init method (although I have done so from a contextInitialized event handler).
My questions are:
1) am I totally off the mark in thinking it is OK to use addServlet() from the the init() method of a Servlet? Should I expect this feature to exist in future releases or is it a side-effect that could disappear at anytime?
2) should I be able to use addFilter() from an init() method or is that crazy.