mitalub
Jun 10th, 2008, 09:33 AM
From a jsp, how can I access the URL used to request the page?
For example, assume the user would browse to "http://localhost:8080/servletName/app/viewName"
This is mapped to WEB-INF/jsp/viewNameView.jsp
From within the jsp, I need to get "viewName" (or "/servletName/app/viewName" would do).
Unfortunately ${pageContext.request.requestURL} returns the path to the jsp: "http://localhost:8080/servletName/WEB-INF/jsp/viewNameView.jsp" which is not what I want. I've tried a bunch of other implicint variables to no avail as well.
I could set a model parameter from my Java controller code… something like map.put("url", request.getPathInfo()) but this seems ugly. Request.pathInfo doesn't return anything in the jsp.
Thanks in advance for your help!
For example, assume the user would browse to "http://localhost:8080/servletName/app/viewName"
This is mapped to WEB-INF/jsp/viewNameView.jsp
From within the jsp, I need to get "viewName" (or "/servletName/app/viewName" would do).
Unfortunately ${pageContext.request.requestURL} returns the path to the jsp: "http://localhost:8080/servletName/WEB-INF/jsp/viewNameView.jsp" which is not what I want. I've tried a bunch of other implicint variables to no avail as well.
I could set a model parameter from my Java controller code… something like map.put("url", request.getPathInfo()) but this seems ugly. Request.pathInfo doesn't return anything in the jsp.
Thanks in advance for your help!