This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

init() method

 
Atul Sawant
Ranch Hand
Posts: 304
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is adviced to override init() method but if you are overriding init(ServletConfig) then we need to call super.init(ServletConfig). Why?

I learned that init() is called in init(ServletConfig) of super class so that it can give servletness to the servlet. If that is the case then we can override any init method and then call super.init() so that the servletness of the servlet is gained.

Please let me know if i am unclear.

Thanks for your answer(s)!
 
Clifton Eaton
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Atul Sawant:
It is adviced to override init() method but if you are overriding init(ServletConfig) then we need to call super.init(ServletConfig). Why?


the important reason to call super.init(ServletConfig) is that it sets the ServletConfig object in the servlet. If you overide init(ServletConfig)without calling super.init(SC) You would not be setting the ServletConfig object.
 
Atul Sawant
Ranch Hand
Posts: 304
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Clifton. One more basic question on this. Which method does the container implicitly calls if you have not overrided any init() method from superclass? init() or init(ServletConfig)?
[ April 10, 2007: Message edited by: Atul Savant ]
 
Tridib Samanta
Ranch Hand
Posts: 128
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Container calls both the method. It will call init(confi) followed by init(). If you don't override init(), the default implementation will be called and the default implementaion of init() does nothing.
The container calls init() from inside init(config) method.
[ April 10, 2007: Message edited by: Tridib Samanta ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic