Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getHeader("Referer") not working on Tomcat 4.1.24

 
Aaron Beverly
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello:
I cannot seem to get the referer header by using request.getHeader("Referer").
This method always returns null, unless I a request is secure (SSL), in which case, the referer is set correctly and I can retrieve it via the getHeader("Referer") method.
After experiencing this problem in a fairly complexe application, I simply attempted to retrieve the referer in a short servlet that does nothing but write a hyperlink to itself and attempt to print out the referer. All I get when making a request via regular HTTP is null. I always get the referer when requesting via HTTPS.
Note: The simple test servlet I wrote DOES return the referer correctly on another installation of Tomcat. Is there something in Apache or Tomcat that I need to change in order to get the referer to show up for ALL requests (assuming that the referer would be defined at all, which in all of these cases, it should be).
Thanks!
Aaron
 
Steve Carton
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you should list all the headers coming in. Something like this?
Enumeration hdrNames = req.getHeaderNames();
while (hdrNames.hasMoreElements()) {
String hdrName = (String)hdrNames.nextElement();
Enumeration hdrValues = req.getHeaders(hdrName);
while (hdrValues.hasMoreElements()) {
String hdrValue = (String) hdrValues.nextElement();
log(hdrName+"="+hdrValue);
}
}

Originally posted by Aaron Beverly:
Hello:
I cannot seem to get the referer header by using request.getHeader("Referer").
This method always returns null, unless I a request is secure (SSL), in which case, the referer is set correctly and I can retrieve it via the getHeader("Referer") method.
After experiencing this problem in a fairly complexe application, I simply attempted to retrieve the referer in a short servlet that does nothing but write a hyperlink to itself and attempt to print out the referer. All I get when making a request via regular HTTP is null. I always get the referer when requesting via HTTPS.
Note: The simple test servlet I wrote DOES return the referer correctly on another installation of Tomcat. Is there something in Apache or Tomcat that I need to change in order to get the referer to show up for ALL requests (assuming that the referer would be defined at all, which in all of these cases, it should be).
Thanks!
Aaron

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic