On Fri, 16 Mar 2001, Paolo Sommaruga wrote:

> Hi,
> 
> I need a way to force the destroy() of one servlet, inside the servlet itself,
>  or to force the download of the servlet from the container.
> At the moment I do something like
> 
>       Thread current = Thread.currentThread();
>       current.destroy();
> 
> but I don't like this to much.
> 

You shouldn't like this -- you just killed one of the servlet container's
threads, which has nothing to do with the destroy() method of a servlet.

> There is a better way to do this with Tomcat ? 
> 

There is no mechanism within the servlet API to acquire an instance of a
running servlet so that you can call it's methods.  The reason for this is
to prevent people from doing exactly what you are trying to do.  Even if
you call the destroy() method yourself, Tomcat would have no clue that
this happened -- it would keep on passing requests to the servlet.

It is the job of the servlet container, not your application, to control
the lifecycle of a servlet.  I would suggest that you redesign your
application so you don't need to do this.

NOTE:  If all you want to do is make Tomcat recognize when your servlet
has changed, you need to set the reloadable="true" value in the <Context>
entry for this web application, in $TOMCAT_HOME/conf/server.xml.

> Thanks for your attention
> 
> 
> 
>                       Paolo Sommaruga
>                       
>                       Garda Access
>                       Garda (Vr), Italy
>                       http://www.garda-access.com/
>               

Craig McClanahan


Reply via email to