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

Servlet Constructor

 
kamlesh tayade
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Servlet is the java class. Is servlet having constructor? If yes then can we overried it else then why it is not.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"kamlesh"

Please see the previous request to change your display name.

We require display names to be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please correct your display name, since accounts with invalid display names get deleted.

thanks,
Dave
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question is answered (eventually) in this thread.

A summary is: Yes you can, but the container only looks for the no-arg constructor. If you do not provide one a Servlet instance will not be created by the container.
 
Talha Bin Hussain
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

A servlet requires info about the server which the server provides thru
the ServletConfig object, so there should be a method in the servlet
which accepts this argument from the server.

But this cannot be a constructor as a servlet is basically an interface
and an interface cannot have constructors. So it should be some other
method. Hence the method init()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic