• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpServletRequest object

 
Sudhanshu Mishra
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am new to servlet programming.I want to know that how is the request processed by a doxxx method of servlet.HttpServletRequest is an interface,but how is then an object of HttpServletRequest passed to the doxxx method ?Does the container implicitly creates the object of HttpServletRequest?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is the responsibility of the container to create both request and response objects, parse the request headers and decide which servlet's service method to call. All of this happens before your code even knows a request is coming.

Assuming your servlet extends HttpServlet - the usual case - you don't have to implement the service method - the default service looks at the requested method and calls doGet, doPost etc. - see the javax.servlet.http.HttpServlet javadocs.

Bill
 
Nam Ha Minh
Ranch Hand
Posts: 502
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sudhanshu Mishra wrote:Hi all,
I am new to servlet programming.I want to know that how is the request processed by a doxxx method of servlet.HttpServletRequest is an interface,but how is then an object of HttpServletRequest passed to the doxxx method ?Does the container implicitly creates the object of HttpServletRequest?


The servlet container must supply objects that implement the HttpServletRequest and HttpServletResponse interfaces and injects them into the doXXX methods. The implementation might be different among different containers, but all should follow the servlet specification.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic