This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

wha is the type of the objects created by container

 
Sony Agrawal
Ranch Hand
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Head First Servlet and JSp book, it says that,
The container sees that the request is for the servlet and creates two objects, HttpServletRequest and HttpServletResponse.

And the object is passed to service() which inturn pass the objects to doXXX().

But what is the actual type of the two objects that are created.. I cant be of the type HttpServletRequest ,HttpServletResponse because they are interfaces .

I am confused. Please correct me
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They will be whatever classes the container provides that implements these interfaces.
 
Sony Agrawal
Ranch Hand
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Sturrock wrote:They will be whatever classes the container provides that implements these interfaces.

Could you please explain this... I could not understand
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4117
195
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is vendor-specific - i.e. specific to the container provider.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you are seeing is just how interfaces work. Something must implement them because, as you've rightly noticed, you cannot instantiate an interface. The Servlet container (e.g. Tomcat) is what provides the implementation. So they are of the type HttpServletRequest and HttpServletResponse (because they inmplement those interfaces), but their concrete implementation will be something else. As far as you are a Servlet/JSP writer you don't need to know/care what that implementation, because you will never use it directly.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're still curious and want to see exactly what classes are implementing these types in your container, paste the following two lines into a JSP and hit it with your browser:
 
Sony Agrawal
Ranch Hand
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys , Now things are clear..
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic