| Author |
wha is the type of the objects created by container
|
Sony Agrawal
Ranch Hand
Joined: Oct 04, 2009
Posts: 143
|
|
In Head First Servlet and JSp book, it says that,
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
Joined: Apr 14, 2004
Posts: 10336
|
|
|
They will be whatever classes the container provides that implements these interfaces.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Sony Agrawal
Ranch Hand
Joined: Oct 04, 2009
Posts: 143
|
|
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
Saloon Keeper
Joined: Jul 29, 2008
Posts: 2729
|
|
|
It is vendor-specific - i.e. specific to the container provider.
|
Author of ExamLab (Download) - the free mock exam kit for SCJP / OCPJP
HELP me! -- Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
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
Joined: Dec 11, 2004
Posts: 13410
|
|
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:
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Sony Agrawal
Ranch Hand
Joined: Oct 04, 2009
Posts: 143
|
|
Thanks guys , Now things are clear..
|
 |
 |
|
|
subject: wha is the type of the objects created by container
|
|
|