Sun Java System Web Server 7.0 Developer's Guide to Java Web Applications

Servlet Types

The two main servlet types are, generic and HTTP.

For both servlet types, you must implement the initializer method init() to allocate and initialize the servlet, and the destructor method destroy() to deallocate resources.

All servlets must implement a service() method, which is responsible for handling servlet requests. For generic servlets, override the service method to provide routines for handling requests. HTTP servlets provide a service method that automatically routes the request to another method in the servlet based on which HTTP transfer method is used. For HTTP servlets, override doPost() to process POST requests, doGet() to process GET requests, and so on.