Getting the Visible Request URL
Hi All,
I would appreciate any help that I can get.
How will it be possible to access the visible request url (in the browser). I have tried ...
request.getRequestURI()
... but this gives me the actual path, which is not what I want users to see. Here is what I mean.
Browser URL : /app/order/viewOrder.html?id=285
Actual URL: /app/WEB-INF/jsp/order/order.jsp
I want a method that will allow me to access the former (browser url). Thanx.
regards
[501 byte] By [
ibn_aziza] at [2007-11-27 2:25:19]

# 1
This is the api specification of your getRequestURI..
getRequestURI()
Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
I wonder how /app/order/viewOrder.html?id=285 is mapped to /app/WEB-INF/jsp/order/order.jsp
# 2
Thank you for the reply, but I am sorry that I was not clear enough with my question. I was not trying to ask about how the Browser URL is mapped to the actual path. I was actually trying to ask how I can get access to the URL string that is VISIBLE in the browser.Much appreciated.
# 4
I am quite puzzled my self, since it does not. For starters it has '/WEB-INF/' as part of the string and this is definitely not what is displayed !I have tried searching for other functions, but alas... of no avail !!
# 5
Until another solution is found, Javascript will have to suffice.... location.href ...it provides the results that I am looking for, but at the expense of Java.
# 7
I was under the impression that this kind of information should be available through the request object.
Anyway, to answer your question, I am looking for this information to be stored into a db at the server side. I am trying to build a tracking system that stores the url that was last accessed by a user.
Hope that helps.
# 10
Just had this exact some issue myself.
The answer can be found in the Servlet Spec Section 8.4.
request.getAttribute("javax.servlet.forward.request_uri")
will get you the original uri received by the first servlet in the chain (before forwarding)
This should be the value you are after.
As an aside, this functionality was originally a bug in Tomcat.
My paging control stopped working when I upgraded from Tomcat5 to Tomcat5.5.
http://issues.apache.org/bugzilla/show_bug.cgi?id=28222
See that page for details, and also a useful function for recreating the full requestURL.
Cheers,
evnafets