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

Creating an object from an interface (like ServletConfig)

 
Deepak Giri
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry, might be the question is too silly but still can't help without asking (the reason might be that my mind has become completely useless at this point)

we know in the life cycle of a servlet, in the early stages, an object of ServletConfig is passed to the init() method (which is called by the container).
but i'm wondering how can we create an object of an interface (which ServletConfig is)???
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to Java in General (with appropriate change of title).
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Giri wrote:how can we create an object of an interface (which ServletConfig is)???

You don't. You create an object of a (concrete) class that implements the interface.

In the specific case of ServletConfig, the container (Tomcat, for example) instatiates a class that implementes ServeltConfig. We don't know which class that is, and more importantly we don't care!
 
Deepak Giri
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks

by the way, can you tell me the exact signature of that init(ServletConfig) method?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's in the JavaDoc.
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the link to the Java API Collection.

You need to check the Enterprise Edition API
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic