在三种情况下,<%=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是从哪里来的,也就是前一个页面。回车,则没有以前的,等同于你新打开一个浏览器,再次输入一样 。刷新,就是重复上一次的操作。
jsp 中 request.getHeader() 相关详细
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: " + getServletConfig().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 : " + session.getCreationTime());
System.out.println("LastAccessed : " + session.getLastAccessedTime());