• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the purpuse of "public no-arg constructor for servlet"

 
chandra kunchala
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,


For Servlets, we should require public no-argument constructor right?

>>Can you tell me, wat is the purpose of that no-argument constructor,
>>Why it should required?
>>Why the servlet should be "public".

Thanks
Chandra




 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please take the time to choose an appropriate forum. This one is for IDEs etc. I'll move this to the Servlets forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chandra kunchala wrote:
>>Can you tell me, wat is the purpose of that no-argument constructor,

Without one the container cannot create an instance of the servlet. But, it's very rare for an explicit constructor to be coded into a servlet. Usually, the default constructor that the compiler provides is used.

>>Why it should required?

See above.

>>Why the servlet should be "public".

How would you expect the container to be able to create an instance otherwise?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic