I would like enable/disable a servlet depending on a context init
parameter.

 

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();

            }

      }

 

Any suggestion?

 

Matteo.

Reply via email to