Calling destroy() method explicitly.

All we know,we can calldestroy() method explicitly in servlets.Does the explicit call to destroy() will affect the default garbage collection mechanism?

e.g

publicclass MyServletextends HttpServlet

{

publicvoid service(){ destroy();}

publicvoid destroy(){}

}

After the code in service() gets executed,will the container can call destroy() again at server shutdown? What are possibleill effects of calling destroy() explicitly ?

[887 byte] By [snikama] at [2007-11-27 6:17:39]
# 1

It's just a Java method. There's nothing special about it at all in terms of Java programming. So it doesn't have any special effects on garbage collection or anything else.

Likewise, if you call it then it executes the code in its body. If the container calls it again then the code in its body is executed again. Nothing more than that (and how would the server even know you called it?) That may be a bad thing or not, depending on the code.

DrClapa at 2007-7-12 17:30:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...