Servlet distroy method

25 views
Skip to first unread message

Nitin Jha

unread,
Aug 29, 2013, 11:10:47 PM8/29/13
to java-bra...@googlegroups.com
What if we override distroy methid in own servlets and how does it works??

Regards
Nitin

nisarg pathak

unread,
Aug 30, 2013, 12:16:30 AM8/30/13
to java-bra...@googlegroups.com
 
hey destroy method can be overridden & you can use that method for closing database/network connections .destroy method will get called when servlet container removes servlet object from the memory when servlet object no longer needed.as servlet object is created for the first request made by client & then after the thread will be spawned for each request made by client.
it is the responsibility of container to explicitely call destroy method of HttpServlet interface.the core implementation of destroy() contains code to garbage collect servlet object & if there are multiple request made for same servlet ,then all corresponding threads can be removed from memory & same Servlet life cycle gets repeated when request to same servlet is made again. 

regards ,
Nisarg pathak







Reply all
Reply to author
Forward
0 new messages