Każdy jest innym i nikt sobą samym.


GenericServlet also contains two log() methods not specified in either the Servlet or the ServletConfig interface. The first takes a String as its argument that will be the message to be written to a servlet log file.
The message will be tagged with the particular servlet's name so you will be able to figure out which message belongs to which servlet. You may want to use this version of log() in the various life−cycle methods so that when init() or destroy() is called a log entry is generated. The second version of the log() method takes an instance of Throwable as its second argument. This signature of log() is implemented in GenericServlet to write the message you specify as the first argument and to write a stack trace for the specified exception into the log file.
The HttpServlet abstract class
HttpServlet extends GenericServlet by adding methods to handle HTTP requests. You saw examples of handling GET and POST requests using the HttpServlet methods doGet() and doPost(). The service methods doDelete(), doHead(), doOptions(), doPut(), and doTrace() are also available to handle DELETE, HEAD, OPTIONS, PUT, and TRACE respectively. Each of these methods takes an HttpServletRequest object and an HttpServletResponse object as arguments, and can throw a ServletException or an IOException.
There are no abstract methods in the HttpServlet class. The service() method, which was abstract in the parent class, is no longer abstract in HttpServlet. Nevertheless, HttpServlet is an abstract class, so you can create servlets by extending it (as in the Hello examples) and overriding one of the service methods. The final method that has been added in HttpServlet is getLastModified(). It can help the client to not reload a page that hasn't changed since the last time he or she accessed it.
The ServletRequest family
The servlet's job is to take a request and generate a response. This means that the servlet must be able to read all the information from the request. Remember that for an HttpServlet the container passes in the handle to the HttpServletRequest and HttpServletResponse objects to the service methods. The HttpServletRequest interface extends the ServletRequest interface. The API also includes the wrapper classes 37
Chapter 3: Creating Dynamic Content with Servlets
ServletRequestWrapper and HttpServletRequestWrapper that you can extend rather than having to implement all the methods in the interfaces.
The ServletRequest interface consists mainly of accessor methods. get...() methods exist for anything you might want to determine from the request of a generic servlet. You can determine the character encoding, content length, and type as well as the names and values of attributes and parameters. You can determine the name and address of the client sending the request as well as the name and port of the server receiving it. In addition, you can determine whether or not the request was made on a secure channel. Three methods are available for making changes to the request. The method removeAttribute() removes the specified attribute from the request, setAttribute() sets the specified attribute to a given value in the request, and setCharacterEncoding() sets the name of the character encoding used in the request.
The HttpServletRequest interface adds four constants and 25 accessors. Each of the constants supports basic authentication. For the most part, the methods return the HTTP−related information. You can get information about sessions, cookies, the query string (the part in the previous example that followed the question mark), the path, and the header. If you are new to working with the Web, this may be a bit confusing. You may not be aware of the amount of information being passed between the client and the server that is never displayed.