Matteo Turra wrote: > I would like enable/disable a servlet depending on a context init > parameter.
Have a look at the Servlet specification, and therein the chapter about Servlet Life Cycle. > I wrote this code in my servlet. But I'm not sure I the best way to do > it. > > public void init() { > > String param = > this.getServletContext().getInitParameter("PARAM"); > > if ("ON".equalsIgnoreCase(param)) { > > System.out.println("Servlet: ON"); > > super.init(); > > } else { > > System.out.println("Servlet: OFF"); > > this.destroy(); > > } > > } I think that might throw things into a kind of loop: the container could keep on trying to initialize the servlet. > Any suggestion? >From the specification (but please get the spec in order to read this in proper context): <<< During initialization, the servlet instance can throw an UnavailableException or a ServletException. In this case the servlet must not be placed into active service and must be released by the servlet container. The destroy method is not called as it is considered unsuccessful initialization. >>> -- ..Juha --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]