wood burning stoves 2.0*
The moose likes Servlets and the fly likes service() method in servlet class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "service() method in servlet class" Watch "service() method in servlet class" New topic
Author

service() method in servlet class

Abhinav Kumar Mishra
Greenhorn

Joined: Jul 25, 2011
Posts: 6
I am beginner in servlets and following Head First book.

The signature of service() method is like as service(HttpServletRequest request,HttpServletResponse responce){}.These two parameters of service() method are reference
variable of interface HttpServletRequest and HttpServletResponce respectively.

When Container invokes the service() method, it should must pass the object of some class which has implemented HttpServletRequest interface or HttpServletResponse interface respectively as an argument to service() method.

am I thinking in right way?
If yes,then please tell me what is the name of class which has implemented the HttpServletRequest interface and HttpServletResponse interface?
if no,then what is the parameter that Container passed as an argument to service(HttpServletRequest request,HttpServletResponse responce){} method while invoking it?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60741
    
  65

Abhinav Kumar Mishra wrote:am I thinking in right way?

Correct.

If yes,then please tell me what is the name of class which has implemented the HttpServletRequest interface and HttpServletResponse interface?

It's not important. Each container will create its own implementation. That's the beauty of interfaces -- we don't have to care!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4338
    
    7

Bear Bibeault wrote:
It's not important. Each container will create its own implementation. That's the beauty of interfaces -- we don't have to care!

But if you really want to know, just get it to output the value of request.getClass().getName() and response.getClass().getName().
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: service() method in servlet class
 
Similar Threads
How container Handle request
SingleThreadModel
which service() method is called
HttpServletRequest / HttpServletResponse.......puzzled!!!
Default implementation of service method in HttpServletClass