Like other Java technology-based components, servlets are platform independent Java classes that are
compiled to platform-neutral byte code that can be loaded dynamically into and run by a Java technology enabled Web server. Containers, sometimes called servlet engines, are Web server extensions that provide servlet functionality. Servlets interact with Web clients via a request / response paradigm implemented by the servlet container.
As you can see in the figure below, a client sends a request to web server, server forwards that request to a servlet, servlet generates dynamic content, mostly in the form of HTML pages, and returns it back to the server, which sends it back to the client. Hence we can say that servlet is extending the functionality of the web server (The job of the earlier servers was to respond only to request, by may be sending the required html file back to the client, and generally no processing was performed on the server)