• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How container Handle request

 
Gaurav Gambhir
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

All servlets extend HttpServlet and it has a method service()

My question is when a request come for a servlet which sequence is right


The container calls the service(ServletRequest,ServletResponse) method of HttpServlet and then the service(ServletRequest,ServletResponse) method of HttpServlet calls service(HttpServletRequest,HttpServletResponse) method of the same class,as the service() method is overloaded in HttpServlet class.

or

Container directly call the service(HttpServletRequest,HttpServletResponse) method

and why,Please explain.

Thanks & Regards
Gaurav
 
Mahendar Reddy
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The container calls the service(ServletRequest,ServletResponse) method of HttpServlet and then the service(ServletRequest,ServletResponse) method of HttpServlet calls service(HttpServletRequest,HttpServletResponse) method of the same class,as the service() method is overloaded in HttpServlet class.



As I know above statement is correct.

Why b'coz for non http request logic is provided in service(ServletRequest,ServletResponse) method. Keep in mind that u have to override this method. In this method the container checks if it is http or non-http.If it is http it is forwarded to service HttpServletRequest,HttpServletResponse) method.
[ March 05, 2006: Message edited by: Mahendar Reddy ]
 
Gaurav Gambhir
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx for reply

But Deshmukh's Book says
If you override the service method in your servlet class, you will loose the functionality provided by the HttpServlet class and the doXXX() methods will not be called automatically.In your implementation, you will have to determine the HTTP method used in request and then you will have to call the appropriate doXXX() method yourself.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic