The J2EETM Tutorial
Home
TOC
PREV TOC NEXT Search
Feedback

What is a Servlet?

A servlet is Java programming language class used to extend the capabilities of servers that host applications accessed via a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by web servers. For such applications, Java Servlet technology defines HTTP-specific servlet classes.

The javax.servlet and javax.http.servlet packages provide interfaces and classes for writing servlets. All servlets must implement the Servlet interface, which defines life cycle methods.

When implementing a generic service, you can use or extend the GenericServlet class provided with the Java Servlet API. The HttpServlet class provides methods, such as doGet and doPost, for handling HTTP-specific services.

This chapter focuses on writing servlets that generate responses to HTTP requests. Some knowledge of the HTTP protocol is assumed; if you are unfamiliar with this protocol, you can get a brief introduction to HTTP in HTTP Overview.

Home
TOC
PREV TOC NEXT Search
Feedback