On 17/07/2013 18:38, Dave wrote: > > 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?
Yes. > Should I expect this feature to exist in future releases No. > or is it a side-effect that could disappear at anytime? Yes. > 2) should I be able to use addFilter() from an init() method No. > or is that crazy. No, but not permitted by the spec. Mark --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org