• Post Reply Bookmark Topic Watch Topic
  • New Topic

parameterized construcor in servlet?

 
Sandeep Bhandari
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what happens if I provide a parameterized constructor in servlet. Will the dynamic loader be able to load the servlet class and call the init/service/doGet/doPost method on it??
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How will the container know which parameter to pass ? You need a non-argument constructor, otherwise the servlet cannot be instanciated.
 
Vishal Matere
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you provide parameterised constructor to servlet then you HAVE to define NON-Parameterized constructor also because compiler mandates you to specify that.

However even after that only NON-parameterized constructor will be called to create new Servlet instance.

V
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!