Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

overloading constructor

 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what happen if we write constructor in servlet?
I mean if there isn't no argument constructor?
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic