• Post Reply Bookmark Topic Watch Topic
  • New Topic

Where is the method body is implemented?  RSS feed

 
Sandeep R Kumar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Inside a servlet ,we call the method getParameter( ) to get the parameter value . This method belongs to 'ServletRequest' which is an INTERFACE . So my question is , since the methods of 'interface' have only declaration , where is the body defined?
Where is the method getParameter() is implemented ???

Please help me in this regard.
 
Ashok Kumar Babu
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When a request is send to a servlet (either doGet or doPost) an instance of Type HttpServletRequest will be send as argument. Interface HttpServletRequest would be implemented by the container.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed. The whole point of interfaces is that you, as a consumer of those interfaces, don't need to worry about the implementation of them.

A concrete class that implements the interface is created by the servlet container (Tomcat, etc) and passed to your servlet.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!