Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HTTPServletRequest Interface  RSS feed

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello EveryBody
We all know that HttpServletRequest is an Interface which extends ServletRequest Interface.
My question is that , Method such as " doGet " takes HTTPServletRequest, HTTPServletResponse as a Parameter BUT the fact is that we can not make objects of an Interface.
So, what will we pass in the doGet method as an Argument ? surely cant pass HTTPServletRequest object.
Thanks in Advance !!!
 
Bartender
Posts: 2155
46
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tarun Oohri wrote:So, what will we pass in the doGet method as an Argument ? surely cant pass HTTPServletRequest object.


A reference to an instance of any class that implements HTTPServletRequest.
When you see a type in a method signature, you may pass to it any child of that type .
EDIT:
But you do not pass anything to this particular method because of what Ulf said below...
 
Rancher
Posts: 42975
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not passing anything to it, because your code does not call those methods - they're called by the server during handling an incoming request. The server is capable of creating objects that implement those interfaces.
 
Tarun Oohri
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:You're not passing anything to it, because your code does not call those methods - they're called by the server during handling an incoming request. The server is capable of creating objects that implement those interfaces.



Thanks Pawel & Ulf for clearing my concepts . I must say CodeRanch people are the best to make one learn java in true sense.
Thanks Tons!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!