5.1. What Is a Servlet?

A servlet is a piece of server-side Java that responds to requests coming in from a client. Although servlets can be created for any protocol that is based on requests and responses, by far the overwhelming majority of servlets are built to handle HTTP requests. In this book, we'll only consider HTTP servlets.

Servlets are frequently compared to applets, and considered a server-side replacement for applets. However, in functionality, what they really replace are CGI scripts (see Chapter 4). Servlets don't provide all of the user interface flexibility that applets can provide, and in fact some deployments of servlets use applets as the client-side technology. HTML is the most widely used presentation option, and our servlets ...

Get J2EE™ and JAX™: Developing Web Applications and Web Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.