• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

request.getHeader("Referer")  RSS feed

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I have 2 jsp pages, first.jsp redirects to second.jsp

first.jsp
<%
response.sendRedirect("http://localhost:8080/seccond.jsp");
%>


On second.jsp i'm using request.getHeader("Referer") to get the url of where i've just come from, but request.getHeader("Referer") is null

second.jsp
<%
out.println(request.getHeader("Referer"));
%>


can anyone tell me what i'm doing wrong?

Thanks for any help
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by dale con:
...
On second.jsp i'm using request.getHeader("Referer") ...


Hi Dale,

You might try the following codes to check the headers name/value. You might should use request.getHeader("referer") instead.

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

-Swapan
 
dale con
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Thanks for your code. I've tried request.getHeader("referer") but i still get a null value ad i also tried


Enumeration e = request.getHeaderNames();

while (e.hasMoreElements())
{
String name = (String)e.nextElement();
String value = request.getHeader(name);
out.println(name + " = " + value);
}


But i don't get the Referer: .....
 
Author and ninkuma
Marshal
Posts: 66806
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As you have seen the referrer header cannot be counted upon. What were you planning to use it for?
 
dale con
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's OK

I can use request.getParameter

Thanks
 
Swapan Mazumdar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by dale con:
It's OK

I can use request.getParameter

Thanks


Hi Dale,

Can you explain how did you help yourself. Theoretically headers and form-data are so much different. What did you want to perform and how did you achieve it. I am just being curious.

-swapan
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66806
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My assumption was that originally the OP was using the value of the referrer to switch behavior on the target page. This is not a good way to do this even if the referrer value was reliable since it creates artificial binding between the pages. Now, I assume that the OP is passing an explicit parameter to cause the page to change its behavior which is a much better approach.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!