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

mohan paladi
Greenhorn

Joined: Dec 13, 2006
Posts: 8
hi friends,
I would like to know why the servlet doesnot have a
constructor.
A brief explanation is needed, the orielly servlet book
doenot give a satisfactory reason.
thanks in advance.
regards
- mohan
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
A servlet may have a constructor, but only one which takes no parameters. This is because servlets are dynamically loaded by the servlet container as needed, and the classloader can't know what other parameters you might want to pass to the constructor, or where to get them from.
This is the same with all dynamically loaded classes, which is why the idiom of a user-supplied "init" function is so common in Java APIs.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
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()?.