Servlet in web, how it is used and its advantages ?

web servlet
Web servlet for dynamic function.

Servlet stands for “Server Component”. Traditionally, the client will ask some resource, in return the server will get the response. It will give the the proper response to the client using HTTP protocols.

But we cannot assure that all the resource which clients search will not present in server. Moreover there will be a condition in which the server may not have that particular server. In this scenario, web servlet comes into actions.

Web servlet

Web servlet is mainly present in web server. moreover its a java based program. It gives back the response on behalf of server to client in a form of html, xml and json.

Its a integrated component of web server. If any unrecognizable request raised from user. The server term it as unknown resource. As a result, the request is forwarded to a specific area called web container.

This web container is also called as help management in servlets. Its a important part, because its job is to map the request to specific servlet.

The most common examples of web container : apache, TOMCAT, IBM’s IIS. Its just a java program which saved as “web.xml” in all containers.

On average, a container may have more than 50 servlet present in it. Thus each servlet do a specific task. It has two different tags. They are:
1) Servlet tags
2) Servlet mapping tags

Its helps to generate dynamic pages, where all the information creates at the moment of user’s request. Moreover the web container can converted into other transferrable forms using annotation.


Web servlets have more merits over CGI, mainly it uses common memory area, low cost for communications, light weight. Additionally there’s no need to start a program again for every new request.

Its highly portable. Since it only uses Java programming language. By using this, it didn’t dependent on other platforms like c, c++, ruby for transferring the datum.

Since its using Java, security, memory leak, garbage collection will be taken care by Java virtual machine [JVM]. Even if the number clients increase, it will scale to that required number