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
posted 9 years ago
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.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi