This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

HttpServletRequest can have object?

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a doubt regarding HttpServletRequest.When a servlet container receives request from the client, it was mentioned like , the servlet container creates objects of HttpServletRequest and HttpServletResponse , and the same are passed to the service method of life cycle.


I have a doubt, since HttpServletRequest, HttpServletResponse are interfaces,
if i am right, we cannot create objects of interfaces.Then can anyone let me understand this?


Regards
Suresh
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Every container implements the HttpServletRequest and HttpServletResponse
interfaces , a container actually creates objects of these implementation
objects ,

HttpServletRequest httpServletRequestImpl = new HttpServletRequestImpl();
HttpServletResponse httpServletResponseImpl = new HttpServletResponseImpl();

and populates these and then calls the service method .
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Servlet Container would have made their own classes which implement the interfaces, then pass instances of those implementations on to the servlet code. This is important, basic Java (basic Object Oriented Programming) stuff. See the Java Tutorial and Here is an example of some code using an interface, and some classes that implement the interface (much like what you do with servlets)
 
reply
    Bookmark Topic Watch Topic
  • New Topic