The Java Servlet Architecture

Two packages make up the servlet architecture: the javax.servlet and javax.servlet.http packages. The javax.servlet package contains the generic interfaces and classes that are implemented and extended by all servlets. The javax.servlet.http package contains the classes that are extended when creating HTTP-specific servlets. An example of this would be a simple servlet that responds using HTML.

At the heart of this architecture is the interface javax.servlet.Servlet. It provides the framework for all servlets. The Servlet interface defines five methods. The three most important are as follows:

  • init() method— Initializes a servlet

  • service() method— Receives and responds to client requests

  • destroy() method— Performs ...

Get Pure Java Server 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.