If the JSP was redirected by the front controller, then HttpServletRequest#getRequestURI() will actually return the JSP URI instead of the original URI as the initial client request (as seen in the address bar of the browser).
In the case of forwarding, the original request URI is available as a request attribute with the key identified by RequestDispatcher#FORWARD_REQUEST_URI , which is javax.servlet.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 is available in JSP EL as follows:
${requestScope['javax.servlet.forward.request_uri']}
source share