A servlet is a Java program that runs on the Java-enabled web or application server. It handles a request from the server, processes the request, produces a response, and sends the response back to the server.