EPractice Lab quiz 1 about releasing resource after destroy()
posted 10 months ago
If the container calls the destroy() method on a servlet, who is responsible for releasing resources?
c. Web Server
d. Application Server
Choice A is correct
Resources are not released automatically. If we initialize a connection object in the init() method of servlet, the connection will not be released even after the destroy() method is called. It is up to the developer to release the connection object. But remember, all threads created by this servlet will be done. No more requests will ever be served by this instance. destroy() may be called on the servlet by the container either when all the threads have finished with it or a container defined default timeout has been exceeded.
I think the container will garbage collect some objects after destroy() is invoked. I think the answer should be a and b.