| Author |
Servlet's init() and destroy() method and constructors
|
Shrikant Deshpande
Greenhorn
Joined: May 17, 2010
Posts: 15
|
|
Who calls Servlet's init() and destroy() method?
How and when it gets called? Can we override destroy() method?
Can we have constructor inside servlet class which extends from HttpServlet or GenericServlet?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56168
|
|
Shrikant Deshpande wrote:Who calls Servlet's init() and destroy() method?
The container. (E.g. Tomcat, Weblogic, and so on)
How and when it gets called?
They get called just like any other method. Whne they get called is covered in the Servlet Spec -- when the servlet isplaced into service, and when it is removed from service.
Can we override destroy() method?
Yes, if you have something meaningful to do when the servlet is taken out of service.
Yes, but it's not a customary or useful thing to do.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Manish Singh
Ranch Hand
Joined: Jan 26, 2007
Posts: 160
|
|
|
You should not use the constructor init() method should be enough for your needs
|
 |
 |
|
|
subject: Servlet's init() and destroy() method and constructors
|
|
|