This is not a Java problem ... merely a problem of understanding the overall
architecture.

As the original author pointed out, HttpServletRequest and HttpServletResponse
are interfaces, not classes, so they cannot be instantiated directly.  So where
do they come from?

The servlet engine (such as JRun, Apache JServ, ServletExec, and so on) that
runs your servlet provides internal classes that implement these interfaces,
and work with the rest of the servlet engine to provide the functions described
in the servlet API.  As a servlet author, you do not need to worry about what
the "actual" underlying class is -- all you worry about is receiving request
and response objects, and performing whatever task your servlet is supposed to
do, and writing the response back out.  The servlet engine does all the rest of
the work for you.

If you want to look at how a servlet engine is actually put together, there are
several open source implementations available on the Web, including Acme (don't
know the URL), Jetty (www.mortbay.com), and Apache JServ (java.apache.org).

Craig McClanahan


Yann LE GUERN wrote:

> Of course interfaces can't be instantiated !
> Actually 'req' and 'res' are instances of 2 non abstracts classes which
> could extend any classes.
> The only thing you need to know is that those 2 instances are implementing
> 'HttpServletRequest' and 'HttpServletResponse' interface. That means you can
> invoke methods like getParameter(), getMethod()...
>
> In fact it's sounds like a java problem.
>
> -----Message d'origine-----
> De : Kenia Nimesh <[EMAIL PROTECTED]>
> � : [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> Date : jeudi 4 mars 1999 11:05
> Objet : Can interfaces be instantiated??
>
>     in the function
>
>     public void doPost(HttpServletRequest req,HttpServletResponse res)
>     throws .....
>     {
>
>     }
>
>     Interfaces can't be instantiated.
>     HttpServletRequest and HttpServletResponse are both interfaces
> ....Right!
>     So how can we pass an object of these interfaces to the doPost method??
>
>     Also that HttpServletRequest extends ServletRequest . Since both of
> these are interfaces they have abstract methods which are just declared ..So
> where are all the
>     methods like getParameter(), getMethod() defined???
>
>     Please help me to solve this basic problem
>
>     Nimesh
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to