View HTTP header information in Java

Source: Internet
Author: User

Java is actually very powerful. You can obtain detailed information about the HTTP header for more detailed processing, such as the last modification time of the file.

Code:

void doPost(HttpServletRequest req, HttpServletResponse resp)            throws ServletException, IOException {    Enumeration enum1 = req.getHeaderNames();        log.debug("-----------header----------------->");    while(enum1.hasMoreElements()){        String key = (String)enum1.nextElement();        String value = req.getHeader(key);        log.debug(key + ":" + value);    }    log.debug("<-----------header-----------------");        }

Result:

-----------header----------------->Accept:*/*Referer:http://localhost:9080/UtanWeb/imgsys/main/regTempMgr.htmlAccept-Language:zh-cnAccept-Encoding:gzip, deflateIf-Modified-Since:Thu, 15 Sep 2011 12:13:41 GMTUser-Agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)Host:localhost:9080Connection:Keep-Alive<-----------header-----------------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.