Question: I am trying to pull in the URL as viewed in the browser address bar into a Google Analytics tag. I used the   

 <%
 String getURI=request.getRequestURI();
 %>

method but it's showing me the JSP file name/path rather than what is in the browser.

Am I doing this wrong or is that what is expected since I am doing this in a developer ToolKit on a VM? I have looked through the forums and looked on Google, but can't find an answer to my question, nothing seems to address the possibility of it working differently in a local environment, so I think I have done something wrong.

Answer: 
If a JSP is been [forwarded](http://docs.oracle.com/javaee/6/api/javax/servlet/RequestDispatcher.html#forward%28javax.servlet.ServletRequest,%20javax.servlet.ServletResponse%29) by a front controller, then the [`HttpServletRequest#getRequestURI()`](http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#getRequestURI%28%29) will indeed return the URI of the JSP instead of the original URI as the client initially requested (as visible in the browser's address bar).

In case of a forward, the original request URI is available as a request attribute with a key as identified by [`RequestDispatcher#FORWARD_REQUEST_URI`](http://docs.oracle.com/javaee/6/api/javax/servlet/RequestDispatcher.html#FORWARD_REQUEST_URI), which is [`javax.servlet.forward.request_uri`](http://docs.oracle.com/javaee/6/api/constant-values.html#javax.servlet.RequestDispatcher.FORWARD_REQUEST_URI).

So, this should do:

```
String getURI = request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI);

```

Or when you're still on Servlet 2.5 or older (this constant was introduced in Servlet 3.0):

```
String getURI = request.getAttribute("javax.servlet.forward.request_uri");

```

By the way, it's in JSP EL available as follows:

```
${requestScope['javax.servlet.forward.request_uri']}

```
Yes that is what it is supposed to do. Use request.getRequestUrl(), this will give you complete (http://www...../xyz.jsp)

Edit 
Refer here for description on two method 
<http://docs.oracle.com/javaee/1.3/api/javax/servlet/http/HttpServletRequest.html>

Edit 2 
so in short your query is that you need the filename of tge file you are in at. 

Try something like

```
request.getRequestURI().substring(request.getRequestURI().lastIndexOf("/"))

```

This will give you string welcome.html.if you are inside welcome.html
you can prepend a '/'. 
Not sure if there is a direct method to what you seek