wood burning stoves 2.0*
The moose likes Servlets and the fly likes getHeader( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "getHeader("Referer") not working on Tomcat 4.1.24" Watch "getHeader("Referer") not working on Tomcat 4.1.24" New topic
Author

getHeader("Referer") not working on Tomcat 4.1.24

Aaron Beverly
Greenhorn

Joined: Sep 10, 2003
Posts: 19
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

Joined: Jan 21, 2003
Posts: 4
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

 
 
subject: getHeader("Referer") not working on Tomcat 4.1.24