• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HttpServletRequest and response

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

I have a question: HttpServletRequest request , HttpServletResponse response ..... are interfaces.
then how is is possible to use them like.... request.getMethode() or response.sendRedirect()?
How we can use them as a object?
Is their any implementation internally?
PLease help me to solve this confusion....
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Malhar More wrote:How we can use them as a object? Is their any implementation internally?


Yes. Implementation provided by the web container.
 
Malhar Me
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

1. The servlet container creates an HttpServletRequest and HttpServletResponse objects and passes them as an argument to the servlet's service methods (doGet, doPost, etc).
2. Here Servlet container create objects like : HttpServletRequest request = new HttpServletRequestWrapper();
HttpServletResponse request = new HttpServletResponseWrapper();
3. So thats why we can directly use the request and response as a object.

Please verify.. tell me whether I am right or wrong .
 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actual implementation is vendor specific but you don't have to worry about it since they are proper implementation(s) of those interfaces (HttpServletRequest etc..). Actually, those wrapper classes do wrap (decorate) the actual request/response objects (those are provided by the container) so they are used as convenient classes if you want to override only few methods defined in those interfaces. Those wrapper classes by default calls the methods on the object (request/response etc..) they decorate. Did I confuse you ?
 
Malhar Me
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks... for clear the query.
I am looking for that class which implements this interfaces and which container uses. I am just thinking that these are the classes which responsible to create a object.

Its vendor specific, so then now its no confusion.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

e.g. the Tomcat web container handles the HTTP request from a client and provides you with an instance of the concrete class 'org.apache.catalina.connector.RequestFacade' which extends 'java.lang.Object' and implements 'javax.servlet.http.HttpServletRequest'. The response object is of type 'org.apache.catalina.connector.ResponseFacade' which extends 'java.lang.Object' and implements 'javax.servlet.http.HttpServletResponse'.
 
When evil is afoot and you don't have any arms you gotta be hip and do the legwork, but always kick some ... tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic