• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

init method of Servlet

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,

Can anybody explain me the difference between init(ServletConfig config)
method and init() method.
API says simply override no arg init() method which will be called by
init(ServletConfig config) method? What do you mean by this?

Kindly explain.....................


regards,
Amit Kulkarni
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

GenericServletClass implements ServletConfig and Servlet Interface.

the default behavior of GenericServlet class is when init() is invoked it calls init(ServletConfig) this class now has reference of ServletConfig from Servlet Container.
the extending class has to call getServletConfig() to get reference of Config from container.

getServletConfig() method call can be avoided /Extending class can obtain ServletConfig reference by calling super.init(ServletConfig).

Hope this clarifies your doubt.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the basic difference I know,

init(ServletConfig) is called by the servlet container to indicate to a servlet that the servlet is being placed into service.

init() is the method you override for doing some stuff at the time of initialization. init() method is called by GenericServlet.init(ServletConfig)
 
Wink, wink, nudge, nudge, say no more, it's a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic