This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet constructor

 
mohan paladi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic