request.getHeader() 相关详细

在三种状况下,request.getHeader("REFERER")取值
1:经过连接跳过来 
2:在地址栏中输入URL,打回车
3:刷新 

当连接过来的时候,referer的值是连接过来的页面的URL,正常。我刷新的时候referer的值没有变,但当我在地址栏中打回车(URL没有改变,只是打回车),referer值却变成NULL了。 

1):连接过来和在地址栏中直接输入URL,有没有什么区别?若是有,有什么区别? 
2):刷新的时候URL为何不变,为何仍是前一个URL地址,为何不变成当前的URL? 
3):直接输入为何得不到 <%=request.getHeader("REFERER")的值?

若是是直接在浏览器里输入有referer的页面,返回是null,也就是说referer只有从别的页面点击链接来到这页的才会有内容。为NULL就是手工,非null就是链接过来的。刷新的时候,会检查服务端是否会有更新,没有的话,则使用本机的缓存,也就是说,你刷新时获得的响应依然是
前一次获得的服务端的内容,由于你的jsp文件没有变化。
referer是从哪里来的,也就是前一个页面。回车,则没有之前的,等同于你新打开一个浏览器,再次输入同样 。刷新,就是重复上一次的操做。

 request.getHeader() 相关详细html

 

//获取客户端向服务器端传送数据的协议名称浏览器

System.out.println("rotocol: " + request.getProtocol()); 缓存

//返回的协议名称.默认是http
System.out.println("Scheme: " + request.getScheme()); 服务器

//能够返回当前页面所在的服务器的名字;若是你的应用部署在本机那么其就返回localhost或者127.0.0.1 ,这两个是等价的网络

System.out.println("Server Name: " + request.getServerName() );session

//能够返回当前页面所在的服务器使用的端口,就是8083
System.out.println("Server Port: " + request.getServerPort()); 
 //request.getRemoteAddr()是得到客户端的ip地址
System.out.println("Remote Addr: " + request.getRemoteAddr()); app

  //request.getRemoteHost()是得到客户端的主机名。
System.out.println("Remote Host: " + request.getRemoteHost()); jsp

//返回字符编码
System.out.println("Character Encoding: " + request.getCharacterEncoding()); 编码


System.out.println("Content Length: " + request.getContentLength()); xml

//定义网络文件的类型和网页的编码,决定浏览器将以什么形式、什么编码读取这个文件,
System.out.println("Content Type: "+ request.getContentType()); 

//若是servlet由一个鉴定方案所保护,如HTTP基本鉴定,则返回方案名称
System.out.println("Auth Type: " + request.getAuthType()); 

//返回HTTP请求方法(例如GET、POST等等)
System.out.println("HTTP Method: " + request.getMethod()); 

//返回在URL中指定的任意附加路径信息。
System.out.println("path Info: " + request.getPathInfo()); 

 //返回在URL中指定的任意附加路径信息,被子转换成一个实际路径
System.out.println("path Trans: " + request.getPathTranslated()); 

//返回查询字符串,即URL中?后面的部份。
System.out.println("Query String: " + request.getQueryString()); 

//若是用户经过鉴定,返回远程用户名,不然为null。
System.out.println("Remote User: " + request.getRemoteUser()); 

//返回客户端的会话ID 
System.out.println("Session Id: " + request.getRequestedSessionId()); 

//返回URL中一部分,从“/”开始,包括上下文,但不包括任意查询字符串。 
System.out.println("Request URI: " + request.getRequestURI()); 

 //返回请求URI上下文后的子串  
System.out.println("Servlet Path: " + request.getServletPath()); 

//返回指定的HTTP头标指。若是其由请求给出,则名字应为大小写不敏感。   
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 : " + session.getCreationTime()); 
System.out.println("LastAccessed : " + session.getLastAccessedTime());

 

//若是在地址栏中输入URL,打回车,地址 http://localhost:7080/nadlibrary/book/user/booklist

rotocol: HTTP/1.1

Scheme: http

Server Name: localhost

Server Port: 7080

Remote Addr: 127.0.0.1

Remote Host: 127.0.0.1

Character Encoding: utf8

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: E2D9AD01880BDC232A134FFCCE280941

Request URI: /nadlibrary/book/user/booklist

Servlet Path: /book/user/booklist

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Host: localhost:7080

Referer : null

Accept-Language : zh-CN,zh;q=0.8

Accept-Encoding : gzip,deflate,sdch

User-Agent : Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17

Connection : keep-alive

Cookie : JSESSIONID=E2D9AD01880BDC232A134FFCCE280941

Created : 1358671508064

LastAccessed : 1358671508517

 

若是超连接(上一个页面是http://localhost:7080/nadlibrary/index经过这个页面上的超连接访问http://localhost:7080/nadlibrary/book/user/booklist)

rotocol: HTTP/1.1

Scheme: http

Server Name: localhost

Server Port: 7080

Remote Addr: 127.0.0.1

Remote Host: 127.0.0.1

Character Encoding: utf8

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: C458CE3A2B03AFA4C2AE1497036221CD

Request URI: /nadlibrary/book/user/booklist

Servlet Path: /book/user/booklist

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Host: localhost:7080

Referer : http://localhost:7080/nadlibrary/index

Accept-Language : zh-CN,zh;q=0.8

Accept-Encoding : gzip,deflate,sdch

User-Agent : Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17

Connection : keep-alive

Cookie : JSESSIONID=C458CE3A2B03AFA4C2AE1497036221CD

Created : 1358671583536

LastAccessed : 1358671583958

相关文章
相关标签/搜索