tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matteo Turra" <mtu...@kion.it>
Subject Enable/Disable servlet via context param
Date Thu, 15 Nov 2007 17:13:47 GMT
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.


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message