How can I get request URL in JSP which is forwarded by Servlet?
If I run following code in JSP,
System.out.println("servlet path= " + request.getServletPath());
System.out.println("request URL= " + request.getRequestURL());
System.out.println("request URI= " + request.getRequestURI());
then I get the server side path to the JSP. But I want to get the URL as you can see in browser’s address bar. I can get it in the Servlet that forwards to the JSP, but I want to get it within the JSP.
If you use
RequestDispatcher.forward()to route the request from controller to the view, then request URI is exposed as a request attribute namedjavax.servlet.forward.request_uri. So, you can useor