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

implementation of interface

 
padmaratna kamble
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends .......
please tell me, in servlet we use HttpServletRequest to get
data Comming from clint. we use
request.getParameter();

and i know Container create object of HttpServletRequest, but how ?.
we know interface does not have method body , how containter know that this method is for to get request parameter from client
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The container creates an instance of some class that implements HttpServletRequest. We don't have to know exactly what class that is. Knowing that it implements the interface is enough because that guarantees the methods we want to use will be there.

If you look at your request.getClass().getName() you'll likely find the container vendor in the package path. When someone decides to write a container, they have to provide implementations of many such interfaces. The behavior they have to provide is so well defined by the spec that we can move code from one container to another, one concrete implementation class to another, and it all still works. Very cool.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic