aspose file tools*
The moose likes Servlets and the fly likes overriding init() and destroy() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "overriding init() and destroy()" Watch "overriding init() and destroy()" New topic
Author

overriding init() and destroy()

Bob Moranski
Ranch Hand

Joined: Nov 22, 2000
Posts: 177
Hi, why is it that when we override init(aServletConfig) we have to have super.init(aServletConfig) but when we override destroy we do not have to have super.destroy()?
Thanks.
Sean MacLean
author
Ranch Hand

Joined: Nov 07, 2000
Posts: 621
I think it's simply because the parent servlet ussually has some of it's own intiallization to do. When you override it, you have to make sure that you allow it to do what it needs to by calling super. The destroy method, however, doesn't inherently do anything so it doesn't matter if you prevent the parent for running it's destroy by overriding it and not calling super.
Sean
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12779
    
    5
When you override
init(ServletConfig conf)
if you don't call super.init( conf )
then your servlet context does not get initialized correctly. You will get a null when you try to later access the config. This is a fairly common newbie mistake.
Bill
Bob Moranski
Ranch Hand

Joined: Nov 22, 2000
Posts: 177
Thank you guys very much!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: overriding init() and destroy()