Servlets are Java applications running on the server side, just like CGI and server side scripting languages such as ASP or PHP. Servlets can therefore manage HTTP requests and to provide the client with a dynamic HTTP response (thus creating dynamic web pages).
Servlets have several advantages over other server-side technologies. Since they are build in Java, servlets provide a means of improving web servers on any platform, especially servlets that are independent of the web server (unlike Apache modules or Netscape Server API). Indeed, servlets run in a servlet engine, establishing the link between the servlet and the web server. The programmer does not have to worry about technical details such as the network connection, the formatting of the HTTP response ...etc.
A servlet container is a class for manipulating the servlet.
On the other hand servlets are much better than the scripts, as they are pseudo-codes, automatically loaded when the server starts or when the connection from client is initiated. Servlets are active (memory-resident) and ready to handle requests from clients, whereas with scripts, a new process is created for each HTTP request.
One of the major advantages of servlets is their reusability. You can create components encapsulating similar services, in order to reuse them in future applications.