This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Servlet Constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Constructor" Watch "Servlet Constructor" New topic
Author

Servlet Constructor

kamlesh tayade
Ranch Hand

Joined: Sep 21, 2005
Posts: 34
As Servlet is the java class. Is servlet having constructor? If yes then can we overried it else then why it is not.


Kamlesh
Be oN edGE SCJP 1.4, on edGE for SCWCD 1.4
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"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

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Feb 12, 2006
Posts: 6
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()
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet Constructor
 
Similar Threads
can i called the constructor in servlet file?If Yes how can?If no why?
init and constructor in servlet
writing own constructor for servlet
Why dont we write constructors in servlets?
in simple servlet ,why a constructor has super()?.