• Post Reply Bookmark Topic Watch Topic
  • New Topic

super.init(config) in servlets  RSS feed

 
sai prasanna
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all

by super.init(config) we can get
intialization parameters and
we can place variables which should be initialized once other than this is there any need of super.init(config) in servlets?

thanks in advance
saiprasanna
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In servlets, if you override the init() method, you'll have to store the ServletConfig somewhere. You can either
1. Declare a ServletConfig class member
2. Or let the parent class store it, by calling super.init(config)
 
Harpreet Hira
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
init(ServletConfig config) -
1. Called by Sevlet Container to indicate that the servlet is ready for service.
2. The implementation of this method in GenericServlet stores ServletConfig for later use, which can be retreived later using getServletConfig().
3. When overriding this method, call super.init(config). However, instead of overriding this method it is better to override init(). init() will be called from init(ServletConfig), and you won't need to to call super.init(config).
4. init(ServletConfig) is called once after instantiating servlet.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!