A Servlet is a direct replacement of the old CGI programs. It is a Java program that gets executed on the server when a form is submitted. The servlet will make the decision of what to do next, based on the form that submitted the information.