This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "overloading constructor" Watch "overloading constructor" New topic
Author

overloading constructor

sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1071
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


Aruna,

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
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

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] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: overloading constructor
 
Similar Threads
IS CONCTRUCTOR IS A METHOD
WA #1.....word association
Can I overload a constructor with enum values?
main method
Constructor doubt - K&B Book