Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

overriding init() and destroy()

 
Bob Moranski
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys very much!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic