How Do Servlets Work?
Basically, servlets process client requests and respond to them. The Survey Application uses HTTP servlets: they extend javax.servlet.http.HttpServlet which in turn extends javax.servlet.GenericServlet. Request data comes to these servlets in an HttpServletRequest object. The servlet calls HttpServletRequest methods to extract: • Servlet parameter names and values. • Remote host name that made the request. • Server name that received the request. • The client’s protocol and version information. • Protocol-specific data, such as methods for accessing HTTP-specific header information for the HTTP protocol. • Input stream data from clients that are using HTTP methods such as POST, GET, and PUT. To respond to requests, the servlets call methods from the HttpServletResponse class to: • Set the content length of the reply. • Set the MIME type of the reply. • Provide an output stream and writer capability so the servlet can send the reply data. • Perform protocol-specific capabilities such as