Chapter 2. A Fast Introduction to Basic Servlet Programming

Topics in This Chapter

  • The advantages of servlets over competing technologies

  • The basic servlet structure and life cycle

  • Servlet initialization parameters

  • Access to form data

  • HTTP 1.1 request headers, response headers, and status codes

  • The servlet equivalent of the standard CGI variables

  • Cookies in servlets

  • Session tracking

Servlets are Java technology’s answer to Common Gateway Interface (CGI) programming. They are programs that run on a Web server, acting as a middle layer between a request coming from a Web browser or other HTTP client and databases or applications on the HTTP server. Their job is to perform the following tasks, as illustrated in Figure 2-1.

Figure 2-1. The role of Web ...

Get More Servlets and JavaServer Pages™ 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.