February 16, 2009 at 11:50 PM
The default service() method in an HTTP Servlet routes the request to another method based on the HTTP transfer method (POST, GET, etc.) For example, HTTP POST requests are routed to the doPost() method, HTTP GET requests are routed to the doGet() method, and so on. This enables the servlet to perform different processing on the request data depending on the transfer method. Since the routing takes place in service(), you generally do not override service() in an HTTP servlet. Instead, override doGet() and/or doPost(), etc., depending on the type of request you expect.
So You must override the service() method (for generic Servlets) or the doGet() and/or doPost() methods (for HTTP Servlets) to perform the tasks needed to answer the request. Very often, this means accessing EJBs to perform business transactions, collating the needed information (in the request object or in a JDBC ResultSet object), and then passing the newly generated content to a JSP for formatting and delivery back to the client.