| Author |
request.getHeader("Referer")
|
dale con
Ranch Hand
Joined: Apr 15, 2005
Posts: 93
|
|
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
|
 |
Swapan Mazumdar
Ranch Hand
Joined: Jul 23, 2003
Posts: 83
|
|
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
Joined: Apr 15, 2005
Posts: 93
|
|
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: .....
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
|
As you have seen the referrer header cannot be counted upon. What were you planning to use it for?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
dale con
Ranch Hand
Joined: Apr 15, 2005
Posts: 93
|
|
It's OK I can use request.getParameter Thanks
|
 |
Swapan Mazumdar
Ranch Hand
Joined: Jul 23, 2003
Posts: 83
|
|
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 opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
|
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.
|
 |
 |
|
|
subject: request.getHeader("Referer")
|
|
|