The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Trail: Servlets
Lesson: Overview of Servlets

Architecture of the Servlet Package

The javax.servlet(in the API reference documentation) package provides interfaces and classes for writing servlets. The architecture of the package is described below.

 

The Servlet Interface

The central abstraction in the Servlet API is the Servlet (in the API reference documentation)interface. All servlets implement this interface, either directly or, more commonly, by extending a class that implements it such as HttpServlet(in the API reference documentation)

The Servlet interface declares, but does not implement, methods that manage the servlet and its communications with clients. Servlet writers provide some or all of these methods when developing a servlet.

 

Client Interaction

When a servlet accepts a call from a client, it receives two objects:

ServletRequest and ServletResponse are interfaces defined by the javax.servlet package.

 

The ServletRequest Interface

The ServletRequest interface allows the servlet access to:

Interfaces that extend ServletRequest interface allow the servlet to retrieve more protocol-specific data. For example, the HttpServletRequest(in the API reference documentation)interface contains methods for accessing HTTP-specific header information.

 

The ServletResponse Interface

The ServletResponse interface gives the servlet methods for replying to the client. It:

Interfaces that extend the ServletResponse interface give the servlet more protocol-specific capabilities. For example, the HttpServletResponse(in the API reference documentation)interface contains methods that allow the servlet to manipulate HTTP-specific header information.

 

Additional Capabilities of HTTP Servlets

The classes and interfaces described above make up a basic Servlet. HTTP servlets have some additional objects that provide session-tracking capabilities. The servlet writer can use these APIs to maintain state between the servlet and the client that persists across multiple connections during some time period. HTTP servlets also have objects that provide cookies. The servlet writer uses the cookie API to save data with the client and to retrieve this data.
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Copyright 1995-2001 Sun Microsystems, Inc. All rights reserved.