Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

HttpServletRequest object

 
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 530
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Let me tell you a story about a man named Jed. He made this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic