Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

service() method in servlet class

 
Abhinav Kumar Mishra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64970
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!

 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic