Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getHeader("Referer") returns null  RSS feed

Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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) {
else {
if (browserName != "Netscape" || browserVer != 2)
+ scrollsOption + ",resizable=no");
} = "9kZF4Fw8lOLitrXrl9rcj3wbNLs2jg1qzrJsSIn2V078rOf5gjB4!1521296358!170405968!7501!7502";
<a href="javascript:windowOpener('http://localhost:7501/w/c/n', 417, 470,'note',true);">localhost new window </a>
<a href="http://localhost:7501/w/c/n">localhost new window </a>

<% String referer=request.getHeader("Referer");
System.out.println("domain 1 is :"+domain+":");
System.out.println("referer is :"+referer+":");
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("")!=-1){%>
if (window.opener)
window.opener.location = '<%=domain%>';
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
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!