After the import statements, type the class declaration (in black text below):
import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class ServletSample extends HttpServlet { }
The example, ServletSample, extends the javax.servlet.http.HttpServlet class of the javax.servlet.http package. Java requires the declared classname to match the name of the java file ServletSample.java. The HttpServlet class, which is a subclass of GenericServlet, provides specialized methods for handling HTML forms. HTTP servlets enable you to send and receive data using an HTML form.
HTML forms are defined by the <FORM> and </FORM> tags. The forms typically include input fields (such as text entry fields, check boxes, radio buttons, and selection lists) and a button to submit the data. They also specify which program or servlet the server should run when the information is submitted.