What is a Container?

Tomcat is an example of a Container. When your web server application (like Apache) gets a request for a servlet (as opposed to, say, a plain old static HTML page), the server hands the request not to the servlet itself, but to the Container in which the servlet is deployed. It’s the Container that gives the servlet the HTTP request and response, and it’s the Container that calls the servlet’s methods (like doPost() or doGet()).

The Container gives your web app communications support, lifecycle management, multithreading support, declarative security, and support for JSPs, so that you can concentrate on your own business logic. response object that servlets (and other parts of the web app) can use to get information about the request and send information to the client.

A typical servlet is a class that extends HttpServlet and overrides one or more service methods that correspond to HTTP methods invoked by the browser (doGet() doPost(), etc.).

The deployer can map a servlet class to a URL that the client can use to request that servlet. The name may have nothing to do with the actual class file name.