wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes How container Handle request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "How container Handle request " Watch "How container Handle request " New topic
Author

How container Handle request

Gaurav Gambhir
Ranch Hand

Joined: Mar 04, 2006
Posts: 254
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

Joined: Sep 27, 2005
Posts: 73

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 ]

SCJP- 98%<br />SCWCD-92%
Gaurav Gambhir
Ranch Hand

Joined: Mar 04, 2006
Posts: 254
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How container Handle request