⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e1044. processing a head request in a servlet.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
By default, a HEAD request is automatically processed by the HttpServlet.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 resetBuffer() does nothing in a HEAD request. Therefore, if resetBuffer() is used during servlet processing, a GET and HEAD request may return different content lengths. 

    // 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");
    }

 Related Examples 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -