A servlet is a Java class that can be loaded dynamically to the server and provide additional functionality to the server. So a request to the server can be handled by a servlet. For example, servlets can be used to retrieve information from a database, process data from an XML file and generate dynamic HTML web pages. Any java-enables web server can offer specilized services using servlet. The Servlet application program interface (API) was designed to extend any type of server.
The servlets can be used for (1)Dynamic Web page generation (2)Information retrieval (3) Retrieving multimedia applications (4) Client/server applications
Java Servlets have many advantages.
(1) Portablility
Since servlets are Java class files it can be developed and deployed across platforms. The Servlet API is tightly integrated into the server. The Servlet API has been designed to be easily extensible to fit the developer's needs.
(2) Scalability
Java is a development environment that comes with a wealth of built-in tools and classes to make development easier and faster. Developers of servlets can use the tools of security and intelligent error handling techniques of Java Programming language.
(3) Efficiency
Servlets are loaded once and then can be accessed many times. The server invokes the servlet using a simple method invocation process, and concurrent requests are handled by separate threads. So the whole system is scalable and perform faster.
The main disadvantage with servlets is the lack of separation of business logic and presentation logic which makes difficult to use in generating Web responses. In order to tune the appearance of the page, one have to edit and recompile the Java servlet, even if the logic is already working.

