Two Laptop Bag*
The moose likes JSP and the fly likes URL of page that sent the request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "URL of page that sent the request" Watch "URL of page that sent the request" New topic
Author

URL of page that sent the request

Rex Rock
Ranch Hand

Joined: Jun 25, 2001
Posts: 82
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

Joined: Apr 17, 2002
Posts: 4
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

Joined: Jan 28, 2002
Posts: 19
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

Joined: Jun 03, 2000
Posts: 5040
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


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Man......I din't know I was in a rece........
- madhav
Tim Hobbs
Greenhorn

Joined: Oct 09, 2003
Posts: 12
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

Joined: Jul 01, 2003
Posts: 65
The correct call is for 'referer', the original programmer misspelled the word and nobody has ever corrected it.
 
 
subject: URL of page that sent the request