Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URL of page that sent the request

 
Rex Rock
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there way to get the url of the page that sent to the request to the current page.
I know i can use hidden variables..and things like that, but am wondering if there is a direct way.
[ April 18, 2002: Message edited by: Rex Rock ]
 
David Southwood
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something like this should do it:

String value = request.getParameter("HTTP_REFERRER");

Note however: the referring page name is sent to the server along with the current page request, but the browser is not required to send this information so it is not 100%.
The only sure way of getting this information for every request would be to use (as you state) hidden fields or url re-writing.
 
Rich Barry
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the request methods....
JSP Request Method: <%= request.getMethod() %>
Request URI: <%= request.getRequestURI() %>
Request Protocol: <%= request.getProtocol() %>
Servlet path: <%= request.getServletPath() %>
Path info: <%= request.getPathInfo() %>
Path translated: <%= request.getPathTranslated() %>
Query string: <%= request.getQueryString() %>
Content length: <%= request.getContentLength() %>
Content type: <%= request.getContentType() %>
Server name: <%= request.getServerName() %>
Server port: <%= request.getServerPort() %>
Remote user: <%= request.getRemoteUser() %>
Remote address: <%= request.getRemoteAddr() %>
Remote host: <%= request.getRemoteHost() %>
Authorization scheme: <%= request.getAuthType() %>
The browser you are using is <%= request.getHeader("User-Agent") %>
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, request.getHeader("referrer");
Its on the request header. Checkout the example on Tomcat. That will give you an idea.
Also, this may not work when you use some of the forward(...) methods. Verify that before you use it.
Good luck.
- madhav
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Man......I din't know I was in a rece........
- madhav
 
Tim Hobbs
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FYI - I know this is old, but I just read this and used it. It didn't work... While "referrer" is the correct spelling, I am using Resin, and it requires "referer". :roll:
 
Randall Stevens
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The correct call is for 'referer', the original programmer misspelled the word and nobody has ever corrected it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic