File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes overloading constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "overloading constructor" Watch "overloading constructor" New topic

overloading constructor

sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1240
what happen if we write constructor in servlet?
I mean if there isn't no argument constructor?
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


I mean if there isn't no argument constructor?

All servlet containers require a default no-argument constructor to create a instance, otherwise your servlet would fail.
Shiraz Khan
Ranch Hand

Joined: Mar 20, 2006
Posts: 51
According to my understanding this no-argument constructor is provided by Compiler just like any other class. Even if you write a no-argument constructor, there should not be any problem.
Please correct me if I am wrong.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63548

Shiraz Khan wrote:Please correct me if I am wrong.
You are wrong.

When you provide your own non-nullary constructor, no default nullary constructor is provided. Therefore, the servlet will fail.

Constructors are not useful notions when it cones to servlets.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: overloading constructor
It's not a secret anymore!