aspose file tools*
The moose likes Servlets and the fly likes HttpServletRequest / HttpServletResponse.......puzzled!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpServletRequest / HttpServletResponse.......puzzled!!!" Watch "HttpServletRequest / HttpServletResponse.......puzzled!!!" New topic
Author

HttpServletRequest / HttpServletResponse.......puzzled!!!

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi,
I am new to servlets and as such facing impediments in my understanding of the subject...at every step. But I am determined to get over it.
Here goes....HttpServletRequest and HttpServletResponse are interfaces and we are required to pass these objects while
calling a servlet. I do not understand how interfaces can be used without they being implemented in the first place.
This is an SOS.
thanks.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
The Java Ranch has a naming policy, described here and "rajendra" is not a valid name. Please choose one which meets the requirements.
Thanks.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
This is a fairly common question, and not just about Servlets. An interface specifies the methods which a class must have if it implements that interface. An interface mey be implemented by as many classes as you like.
In the particular case of HttpServletRequest and HttpServletResponse these two interfaces are implemented inside the servlet container. When a servlet container invokes the service(), doPost(), doGet() (etc.) methods, it first creates an instance of one of its classes, which happens to implement the HttpServletRequest interface, and then passes that class to your servlet. HttpServletResponse is similar.
For a full example of how this is done, get the source code for any servlet container or servlet-capable webserver, and 'find files' or 'grep' for any java files containing the string 'implements HttpServletRequest'.
Rajendra Deshpande
Ranch Hand

Joined: Nov 24, 2000
Posts: 40
Frank Carver,
Thank you for the quick reply.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
And thank you for changing your name so promptly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HttpServletRequest / HttpServletResponse.......puzzled!!!