DEV Community

Saumya Agnihotri
Saumya Agnihotri

Posted on

Introduction to Servlets

While surfing any website on the internet, for any page in it there are two things that happens, request and response between the client and server. Client sends a request to retrieve any page and response comes from the server.

There are basically two types of pages - static and dynamic. Dynamic pages are those pages which are created during run time.

Web containers

So now to understand where servlets fits in this picture, we need to understand something called web containers which are nothing but helper applications which are used to generate these dynamic pages. These helper functions contains servlets for the same purpose. Apache Tomcat is one of the examples for web containers.

Servlets

Now what exactly this servlet does and what it is exactly? It's nothing but a java file which can take the request from the client on the internet and it can process that request and it can provide you a response in the form of an HTML page. It's a normal class that extends HttpServlets

Deployment Descriptor

Now how does this web container will know which servlet is suitable for handling any incoming request. Well, for that we have web.xml files which are also know as deployment descriptor. Here you mention for which request which servlet should be called.

Top comments (0)