Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How did someone get to my site  RSS feed

 
Jeremy Wilkinson
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If someone puts a link back to my site on there site, is there a way to tell where they came from with out using url parameters. For example, website www.xyz.com has link on their site that links to my site www.abc.com. Is there something in the request header that will tell me that the incoming request came through www.xyz.com?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should be fairly easy to write some code that checks the headers. DO a dump of them and see what you find.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hint: it's the misspelled header
 
chets patel
Ranch Hand
Posts: 77
Eclipse IDE Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try

 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That tells you where the user is right now. It doesn't tell you anything about where the user came from.
 
Jeremy Wilkinson
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found it...
It was kind of tricky because header names that are not passed via the request are not populated in the Enumeration object. Here is the code I used to list out the headers from the request.

Enumeration e = request.getHeaderNames();
String name = "";
while (e.hasMoreElements()) {
name = (String) e.nextElement();
System.out.println(name + ": " + request.getHeader(name));
}

... and here is how to get the header that returns the link back URL.
request.getHeader("referer")
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the one. I told you it was misspelled; it should have been called "referrer" but somehow lost one "r". Adding that would cause a lot of broken web apps so the spelling error is there for life.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also be aware the the referer header isn't always set, so your code needs to be able to handle the case where it's not included.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!