Can we override service() method in HttpServlet?

Can we override service() method in HttpServlet?

Postby Kishan » Thu Feb 07, 2013 5:29 am

Can we override service() method when servlet extended from HttpServlet?
Kishan
 
Posts: 191
Joined: Tue Jan 29, 2013 4:21 am

Re: Can we override service() method in HttpServlet?

Postby Kishan » Fri Feb 08, 2013 3:18 pm

You can override service() method from HttpServlet. But it is not recommended.

Reason:
HttpServlet provided implementation for service() method to route the request appropriate doXXX() method based on request method. If the request method GET, it will invoke doGet method method is POST it will invoke doPost method like this.

Hence if you override service() default doXXX method routing won't execute.
Kishan
 
Posts: 191
Joined: Tue Jan 29, 2013 4:21 am


Return to Servlets

Who is online

Users browsing this forum: No registered users and 1 guest

cron