
Figure A.6: The servlet in a Web browser
The descendant has all the methods and fields defined in its ancestor, plus
any new fields or method it decides to implement.
Inheritance is indicated with the
extends keyword followed by the ancestor
name. In Java, a class cannot inherit from more than one class (single
inheritance). In the following example, XDic inherits from HttpServlet:
public class XDic
extends HttpServlet
{
// ...
}
doGet()
Java servlets must inherit from HttpServlet and overwrite one or more
methods among
doGet(), doPost(), and doPut(). Each of these methods cor-
responds to an HTTP command. In Listing A.2, the servlet overwrites
doGet()