aspose file tools*
The moose likes JSP 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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "getHeader("Referer") returns null" Watch "getHeader("Referer") returns null" New topic
Author

getHeader("Referer") returns null

Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1850
Hi,
Any one has any idea as to why the request.getHeader(Referer) info is lost when a page is opened in a new window.
It works fine when opened in the same window.
---HTML PAGE-----
<script language="Javascript">

function windowOpener(url,width,height,name,scrolls)
{
browserName = navigator.appName;
browserVer = navigator.appVersion.substring(0,1);
if (width==null) {width=417;}
if (height==null) {height=470;}
if (name==null) {name="globaltPopup";}
if (scrolls==true) {
scrollsOption="yes";
}
else {
scrollsOption="no";
}
if (browserName != "Netscape" || browserVer != 2)
{
controlWindow=window.open(url,name,"toolbar=no,height="+height+",width="+width+",location=no,directories=no,status=no,menubar=no,scrollbars="
+ scrollsOption + ",resizable=no");
}
}
window.name = "9kZF4Fw8lOLitrXrl9rcj3wbNLs2jg1qzrJsSIn2V078rOf5gjB4!1521296358!170405968!7501!7502";
</script>
<a href="javascript:windowOpener('http://localhost:7501/w/c/n', 417, 470,'note',true);">localhost new window </a>
<br><br>
<a href="http://localhost:7501/w/c/n">localhost new window </a>
<br><br>

<br><br>
-----
JSP PAGE
<% String referer=request.getHeader("Referer");
System.out.println("domain 1 is :"+domain+":");
System.out.println("referer is :"+referer+":");
out.println();
out.println("Request headers:");
Enumeration headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
System.out.println("IN HEADER NAMES");
String name = (String) headerNames.nextElement();
System.out.println("IN HEADER NAMES :"+name);
String value = request.getHeader(name);
System.out.println("IN HEADER NAMES :"+value);
}
if(referer!=null && referer.indexOf("club.nokia")!=-1){%>
if (window.opener)
{
window.opener.location = '<%=domain%>';
self.close();
}
<%}%>
-----
In the new window cases the referer header is null
But when opened in the same window the referer contains a vaild URL.
Any ideas
--------------------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getHeader("Referer") returns null