This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
HttpServletRequest is an interface, How does the servlet container implement this interface to create an object out of it ? Which method in this interface returns an object which implements this interface ?
This is an Interface so that the container knows how to create one, but so that each container is free to create its own concrete implementation of this interface. From point of view of the user, we should only need to know how this class behaves (from the interface) without needing to know how to create one. If you want to know what the actual class is behind the scenes, try
Dave
thomas davis
Ranch Hand
Joined: Feb 01, 2003
Posts: 207
posted
0
If you want to know what the actual class is behind the scenes, try
code: -------------------------------------------------------------------------------- String requestClass = request.getClass().getName() -------------------------------------------------------------------------------- Hi Dave, How come above code creates an object which implements HttpServletRequest interface ?
It doesn't, the container creates an instance and passes it to you. All that you know is that it behaves like the HttpServletRequest interface, you don't need to know exactly what it is. Using the code I gave you, you can see what the implementing class is. It doesn't get created at that stage, it already exists, you're just able to find out what it is.