Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding init() method

 
Chaitanya Vivek
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its on Page#102 of HFSJ.

why is there an init()method? Why is not a constructor enough for initializing a servlet?

Exprts, pls let me know the answer.
 
John Lincoln
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because init does more than just instantiating the servlet. It does all the pre-work like setting up database connection any specific configurations required for the servlet.

HTH

thanks
 
Chaitanya Vivek
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also init() method gives the servlet access to the ServletConfig and ServletContext objects, which the servlet needs to get info abt the servlet config and the web app.

thanks for the reply!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic