Java Reference
In-Depth Information
L
ISTING
3.1
Continued
//Get Servlet information
public String getServletInfo() {
return “BasicServlet Information”;
}
}
Dissecting the
BasicServlet
Now that you have had a chance to look over the source of the
BasicServlet
, let's take a
closer look at each of its integral parts. We will examine where the servlet fits into the JSDK
framework, the methods that the servlet implements, and the objects being used by the servlet.
Where Does the
BasicServlet
Fit into the Servlet
Framework?
The first thing we are going to look at is where the
BasicServlet
fits into the servlet frame-
work. This servlet extends the
HttpServlet
class. The
HttpServlet
class is an abstract class
that simplifies writing HTTP servlets. It extends the
GenericServlet
class and provides the
functionality for handling the HTTP protocol-specific requests. The
BasicServlet
overrides
four of its inherited methods. Figure 3.1 shows where the
BasicServlet
fits into this hierarchy.
3
<<Interface>>
javax.servlet.ServletConfig
<<Interface>>
javax.servlet.Servlet
<<Interface>>
java.io.Serializable
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
BasicServlet
F
IGURE
3.1
The
BasicServlet
depicted in the Servlet Framework.