my dog learned polymorphism*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Question on HttpServletRequest Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Question on HttpServletRequest" Watch "Question on HttpServletRequest" New topic
Author

Question on HttpServletRequest

Ramesh Shanmugam
Ranch Hand

Joined: Sep 13, 2004
Posts: 132
Hi all,

HttpServlet is a class, and HttpServletRequest is a Interface. In an servlet file or in JSP we could able to access request.getParameter(), request.getSession() etc, as HttpServletRequest is a interface, where are these methods defined and how could v able to access those methods.

Thanks in advance,
Ramesh


Ramesh Shanmugam - SCJP 1.5
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

where are these methods defined and how could v able to access those methods.

HttpServletRequest is part of the Servlet specification. There rules are drawn , so it is up to the container to decide how to implement the interface. You'll see different implementations among different containers, but doing the same thing.


[My Blog]
All roads lead to JavaRanch
Ramesh Shanmugam
Ranch Hand

Joined: Sep 13, 2004
Posts: 132
any pls tell me some more detail explanation

Thanks
Ramesh
Daniel Dalton
Ranch Hand

Joined: Mar 20, 2005
Posts: 146
HttpServletRequest is an interface - agreed. Tomcat (for example) will provide a class which implements that interface.

An interface provides a contract between the developer of a class and a user of the class. In particular it guarantees that any class which implements the interface will provide the methods specified in the interface.

Given this, you as a developer don't need to know the name of the class that tomcat provides because you access it via the interface type...

Is that any clearer?
Ramesh Shanmugam
Ranch Hand

Joined: Sep 13, 2004
Posts: 132
hi Daniel,

The explanation which u gave is good. It is clearer..Thx
 
wood burning stoves
 
subject: Question on HttpServletRequest
 
Similar Threads
Using a filter to block access to certain web pages.
Inheritance Question (I think)
EJB 2.0 - Local - Remote
Interface
Accessing default class methods in other packages (Bug??)