• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Question for SCWCD.

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

Somebody might have asked this question before me and many of you might have known the answer. So please share it

It is a simple(may be stupid) question on Servlet.
At last servlet is a class and every class has its constructor. So Container must be calling that constructor in case of servlet for us.

Is that constructor really exists?

But what is in that constructor?

What would happen if we write our own constructor in a servlet?

Thank you,

Sumit
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like any java classes, servlets also have constructors. If you don't write one, there will still be the default constructor. You must have a no-argument constructor, because the container needs it to instanciate it.
You're not supposed to do anything in the constructor. Initialization should be done in the "init" method.
 
I carry this gun in case a vending machine doesn't give me my fritos. This gun and this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic