1

How Get Referer Information In IE

request.getHeader("referer") return null in internet explorer??

im using Java Servlet

here is the code:

String vReferer="";

if(null != request.getHeader("referer")){
 vReferer = request.getHeader("referer").toString();
}else{
 vReferer = "nothing";
}

response.getWriter().print(vReferer);

Output: nothing

how can i get referer value?

muhammadanish
  • 437
  • 2
  • 6
  • 20

3 Answers3

1

From this url

You however need to realize that this is a client-controlled value and can thus be spoofed to something entirely different or even removed. Thus, whatever value it returns, you should not use it for any critical business processes in the backend, but only for presentation control (e.g. hiding/showing/changing certain pure layout parts) and/or statistics.

Community
  • 1
  • 1
chrome
  • 661
  • 2
  • 7
  • 23
1

I think that @chrome is correct. It seems that your IE is configured to hold the privacy data in secret.

Try the following. Once upon a time I developed JSP that prints all HTTP information (including headers) that can be extracted from servlet API. This JSP is located on web site of company I used to work for.

To make your referer header not empty go to google and search for "vringo headers.jsp". Click the first link (something like vringo.com/Melrose/headers.jsp. Scroll down and see referer header. Do this first with other browser, then with IE. If you see the header your browser is configured correctly, so try to find the problem in your testing scenario. If it does not appear in IO check privacy configuration of your browser.

I hope this will help.

AlexR
  • 114,158
  • 16
  • 130
  • 208
0

Note that this variable can be null in many circumstances.

Community
  • 1
  • 1
Brian Agnew
  • 268,207
  • 37
  • 334
  • 440