![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e1044. Processing a HEAD Request in a ServletBy default, a HEAD request is automatically processed by theHttpServlet.doGet() method using a modified response object that
simply counts and discards any characters written to the buffer. If
it is necessary to improve the performance of a servlet that is
frequently accessed with a HEAD request method, you can override the
HttServlet.doHead() method and implement a more efficient
algorithm. Typically, a doHead() implementation sets the content
length and type, as demonstrated by this example.
Note: In the JWSDP 1.0, calling // See also e1035 The Quintessential Servlet // This method is called by the servlet container to process a HEAD request. // There may be many threads calling this method simultaneously. public void doHead(HttpServletRequest req, HttpServletResponse resp) throws IOException { // Set the content length and type resp.setContentLength(123); resp.setContentType("text/html"); }
e1041. Preventing Concurrent Requests to a Servlet e1042. Getting the Requesting URL in a Servlet e1043. Getting a Request Header in a Servlet e1045. Getting the Client's Address in a Servlet © 2002 Addison-Wesley. |