获得Request请求相关参数

\\\\\\\\\\相关信息\\\\\\\\\\\
String url=request.getRequestURL().toString();//http://localhost:8080/myshop/order.do
String que=request.getQueryString();//task=gotoOrder           
from = url + "?" + que;
request.setAttribute("from", from); 

 

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

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


\\\\\\\\\\\\\\\\\\\\\\\\\输出结果\\\\\\\\\\\\\\\\\\\
rotocol: HTTP/1.1
Scheme: http
Server Name: localhost
Server Port: 8080
rotocol: HTTP/1.1
Server Info: Apache Tomcat/6.0.14
Remote Addr: 127.0.0.1
Remote Host: 127.0.0.1
Character Encoding: UTF-8
Content Length: -1
Content Type: null
Auth Type: null
HTTP Method: GET
ath Info: null
ath Trans: null
Query String: task=gotoLogin
Remote User: null
Session Id: D8A6D983BCBED9BE2067D7AEA704D1D0
Request URI: /myshop/users.do
Servlet Path: /users.do
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, application/QVOD, application/QVOD, */*
Host: localhost:8080
Referer :
http://localhost:8080/myshop/product.do?task=getProductByCategoryId&fid=11
Accept-Language : zh-cn,en-us;q=0.5
Accept-Encoding : gzip, deflate
User-Agent : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 661; Maxthon; (R1 1.6); .NET CLR 1.1.4322; .NET CLR 2.0.50727)
Connection : Keep-Alive
Cookie : JSESSIONID=D8A6D983BCBED9BE2067D7AEA704D1D0; myshop.cart=%7B%22ftotleintegral%22%3A56%2C%22list%22%7D%5D%2C%22ftotalmoney%22%3A40%7D
Created : 1282313379078
LastAccessed : 1282314993625
Protocol: HTTP/1.1
Scheme: http
Server Name: localhost
Server Port: 8080
Protocol: HTTP/1.1
Server Info: Apache Tomcat/6.0.14
Remote Addr: 127.0.0.1
Remote Host: 127.0.0.1
Character Encoding: UTF-8
Content Length: -1
Content Type: null
Auth Type: null
HTTP Method: GET
Path Info: null
Path Trans: null
Query String: task=gotoLogin
Remote User: null
Session Id: D8A6D983BCBED9BE2067D7AEA704D1D0
Request URI: /myshop/users.do
Servlet Path: /users.do
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, application/QVOD, application/QVOD, */*
Host: localhost:8080
Referer :
http://localhost:8080/myshop/product.do?task=getProductByCategoryId&fid=11
Accept-Language : zh-cn,en-us;q=0.5
Accept-Encoding : gzip, deflate
User-Agent : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 661; Maxthon; (R1 1.6); .NET CLR 1.1.4322; .NET CLR 2.0.50727)
Connection : Keep-Alive
Cookie : JSESSIONID=D8A6D983BCBED9BE2067D7AEA704D1D0; myshop.cart=%7B%22ftotleintegral
Created : 1282313379078
LastAccessed : 1282314993625

 

/////////////////////////
String sc=request.getScheme();//http
String sn=request.getServerName();//localhost
int sp=request.getServerPort(); //8080 
String cpath=request.getContextPath();//OA
String spath=request.getServletPath();//newsRe.do
String que=request.getQueryString();
  
String ref=request.getHeader("referer");//http://localhost:8080/OA/news.do?method=deploy&newsId=3&pagesize=6
String uri=request.getRequestURI();///OA/newsRe.do
String url=request.getRequestURL().toString();//http://localhost:8080/OA/newsRe.do  

你可能感兴趣的:(tomcat,servlet,Excel,Scheme,silverlight)