Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

basic question...

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why in init method..we need to call
super.init(config)? what is the use of this? When can we use it or skip it?
 
Aziz Ahmed
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If u want to initialize ur servlet to some default values ,while loading, u can use getInitParameter or similar methods found in ServletConfig. thats why u r initializing that. it is useful to establish Database connections.
 
Rahul Agarwal
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
init() method is the first method which gets executed first so it is always better to place code here which u want to be executed first.database connections are such things
rahul
 
cata lin
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
A servlet extends HttpServlet, which extends GenericServlet.
If you write a method called init(ServletConfig sc), you override the old method, and lose the work it was doing. By calling super.init(sc) you take advantage of it, and it's not you problem anymore to write code to properly init all the servlet.


[This message has been edited by cata lin (edited October 18, 2000).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic