A servlet is a Java programming language class that is used to extend the capabilities of servers that host applications accessed by means of a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by web servers. See more about Servlet .
The Servlet interface is the central abstraction of the Servlet API and it defines methods which servlets must implement, see below Servlet root hierarchy.
ExampleThis example is xml based ..
Create a maven web-app archetype project and add below dependencies
Create a servlet class
Deploy application in to any web server and hit the below url