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

mshanua at 2007-7-12 2:33:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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.
ibn_aziza at 2007-7-12 2:33:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
that is what ur getRequestURI() function does..isnt it?
mshanua at 2007-7-12 2:33:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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 !!
ibn_aziza at 2007-7-12 2:33:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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.
ibn_aziza at 2007-7-12 2:33:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Of course. JS is client side and knows absolutely nothing about the server side environments (unless you pass it to it manually or so).Why do you want to know it in the server side by the way? How is this URL mapped?
BalusCa at 2007-7-12 2:33:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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.

ibn_aziza at 2007-7-12 2:33:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
How is this URL mapped? You just need to inverse the mapping.
BalusCa at 2007-7-12 2:33:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
The mapping is something that is taken care of by the Spring framework. So it is nothing that i can use to 'inverse' directly. I need a method that will provide me this information.Many thanx.
ibn_aziza at 2007-7-12 2:33:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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

evnafetsa at 2007-7-12 2:33:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 11
Wow... many thanks !
ibn_aziza at 2007-7-12 2:33:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...