Why there is no constructor in servlet?

  • Every java class will have aleast one constructor and servlets are no exception to this.
  • But while using servlets ,we never instantiate the servlet rather the container does it for us by using the newInstance() defined in the Class class;  which in turn uses the empty(Default) constructor to create a new instance of the servlet.
  • If we define parameterised constructor in the serlet ,then container will fail in instantiating the servlet.
  • The rest is left for you to decide whether a servlets need a user defined constructor or not.


Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email