• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Method called during servlet initialization

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am studying from 2 books i.e Head first Servlets and Jsp and SCWCD Kit by Hanumant Deshmukh.

My problem is that one book says that init(servletconfig) is called during initialization and other book says that init() method is called.

I just want to confirm which method is called?
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both the methods are called during servlet initialization only.

init(servletConfig) is called first.
init() is called from within init(servletConfig).
We can override init() for putting our own servlet initialization code.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The servlet container can't call init(), because it is not part of the Servlet interface. init() is a method of GenericServlet, so it doesn't necessarily exist (because you're free to create servlets that do not extend GenericServlet or its subclass HttpServlet).

This kind of information is generally -and specifically in this case- part of the javadocs.
 
P. Jain
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply. My doubt has been cleared.
reply
    Bookmark Topic Watch Topic
  • New Topic