[Add to favorites] request-Related Object Reference

Source: Internet
Author: User

Import java. util .*;

 

Enumeration e = request. getHeaderNames ();
While (e. hasMoreElements ())
{
String name = (String) e. nextElement ();
String value = request. getHeader (name );
Out. println (name + "=" + value + "<br> ");
}

 

Similar results:

Accept-Language = zh-cn
Cookie = JSESSIONID = abcIACpWXsAl08w1HXJgs
Host = www.test.com
Accept-Encoding = gzip, deflate
User-Agent = Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2;. net clr 1.1.4322;. net clr 2.0.50727;. net clr 3.0.04506.30)
UA-CPU = x86
Accept = */*
Connection = Keep-Alive

 

 

<%
Out. println ("Protocol:" + request. getProtocol () + "<br> ");
Out. println ("Scheme:" + request. getScheme () + "<br> ");
Out. println ("Server Name:" + request. getServerName () + "<br> ");
Out. println ("Server Port:" + request. getServerPort () + "<br> ");
Out. println ("Protocol:" + request. getProtocol () + "<br> ");
Out. println ("Server Info:" + getServletConfig (). getServletContext (). getServerInfo () + "<br> ");
Out. println ("Remote Addr:" + request. getRemoteAddr () + "<br> ");
Out. println ("Remote Host:" + request. getRemoteHost () + "<br> ");
Out. println ("Character Encoding:" + request. getCharacterEncoding () + "<br> ");
Out. println ("Content Length:" + request. getContentLength () + "<br> ");
Out. println ("Content Type:" + request. getContentType () + "<br> ");
Out. println ("Auth Type:" + request. getAuthType () + "<br> ");
Out. println ("HTTP Method:" + request. getMethod () + "<br> ");
Out. println ("Path Info:" + request. getPathInfo () + "<br> ");
Out. println ("Path Trans:" + request. getPathTranslated () + "<br> ");
Out. println ("Query String:" + request. getQueryString () + "<br> ");
Out. println ("Remote User:" + request. getRemoteUser () + "<br> ");
Out. println ("Session Id:" + request. getRequestedSessionId () + "<br> ");
Out. println ("Request URI:" + request. getRequestURI () + "<br> ");
Out. println ("Servlet Path:" + request. getServletPath () + "<br> ");
Out. println ("Accept:" + request. getHeader ("Accept") + "<br> ");
Out. println ("Host:" + request. getHeader ("Host") + "<br> ");
Out. println ("Referer:" + request. getHeader ("Referer") + "<br> ");
Out. println ("Accept-Language:" + request. getHeader ("Accept-Language") + "<br> ");
Out. println ("Accept-Encoding:" + request. getHeader ("Accept-Encoding") + "<br> ");
Out. println ("User-Agent:" + request. getHeader ("User-Agent") + "<br> ");
Out. println ("Connection:" + request. getHeader ("Connection") + "<br> ");
Out. println ("Cookie:" + request. getHeader ("Cookie") + "<br> ");
Out. println ("Created:" + session. getCreationTime () + "<br> ");
Out. println ("LastAccessed:" + session. getLastAccessedTime () + "<br> ");

    
%>

Running result:

Protocol: HTTP/1.1
Scheme: http
Server Name: 192.168.0.1
Server Port: 8080
Protocol: HTTP/1.1
Server Info: JavaServer Web Dev Kit/1.0 EA (JSP 1.0; Servlet 2.1; Java 1.2; Windows NT 5.0x86; java. vendor = Sun Microsystems Inc .)
Remote Addr: 192.168.0.106
Remote Host: abc
Character Encoding: null
Content Length:-1
Content Type: null
Auth Type: null
HTTP Method: GET
Path Info: null
Path Trans: null
Query String: null
Remote User: null
Session Id: To1010mC466113890241879At
Request URI:/c. jsp
Servlet Path:/c. jsp
Accept :*/*
Host: 192.168.0.1: 8080
Referer: null
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)
Connection: Keep-Alive
Cookie: SESSIONID = To1010mC466113890241879At
Created: 965764522168
LastAccessed: 965775587088.

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.