How does servlet container creates an HttpServletRequest object ?
posted 9 years ago
Good morning/Evening to all,
I have come across a thought- how does servlet container creates an HttpServletRequest/HttpServletResponse objects as they are interfaces which can't be instantiated directly. Does that mean there exists a class that implements all the methods declared in these interfaces and the container creates object of those classes.
Hello, The service method accepts two parameters HttpServletRequest and HttpServletResponse.The container for example Tomcat, two classes,one that implements the HttpServletRequest and one that implemenmts the HttpServletRespone.The container passes to the service method an instances of the those two classes and you deal with them according to their interface types.