Servlets can be compared to CGI programs. While CGI programs can be written in Java, Java servlets add additional functionality including security, dynamic loading from remote servers, and the ability to add functionality to your web server. Unlike CGI programs, servlets are loaded once and then stay resident.
Future service calls to the servlet are faster since the servlet is already in memory.
Servlets can maintain state information between service calls. The Servlet API is supported by most major web servers. Instead of subclassing the java.applet.Applet class, you write your servlets by subclassing a class that implements the javax.servlet.Servlet interface. Note that the Applet class extends the java.awt.Panel class which necessitates an interactive interface. It subclasses GenericServlet, a ready-made simple implementation of the Servlet interface.