Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Init and Constructor

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is first invoked when a servlet is fist called? Init or constructor? and why do we need to register servlet with diferent names and have different instances?
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai,
init is not a static method. so it cannot be called with out creating an instance. to creat an instance you must use constructor.
i dont know why you asked this question.
bye
have a good one
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
init method is first called
 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
init() is an instance method. This means that, in order for the servlet to invoke init() it needs to have an instance of your servlet.
aServlet.init();
In order to have a instance of your servlet, the servlet container needs to have executed an statement which might look like this:
aServlet = new YourServlet();
I.e. the constructor gets executed first.
Morale of the story: Brush up on your Java fundas!
[ June 20, 2003: Message edited by: Panagiotis Varlagas ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic