I\'m trying to get a correct current URL in JSP in Spring webapp. I\'m trying to use the following fragment in the JSP file:
${pageContext.request.requestURL}
>
Which Spring version are you using? I have tested this with Spring 3.1.1.RELEASE, using the following simple application:
Folder structure
-----------------------------------------------------------------------------------
spring-web
|
--- src
|
--- main
|
--- webapp
|
--- page
| |
| --- home.jsp
|
--- WEB-INF
|
--- web.xml
|
--- applicationContext.xml
home.jsp
-----------------------------------------------------------------------------------
Welcome to Spring Web!
Page URL: ${pageContext.request.requestURL}
web.xml
-----------------------------------------------------------------------------------
org.example.web
spring-mvc-dispatcher
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
/WEB-INF/webContext.xml
1
spring-mvc-dispatcher
*.htm
applicationContext.xml
-----------------------------------------------------------------------------------
On accessing http://localhost:8080/spring-web/page/home.jsp, the URL is correctly displayed as http://localhost:8080/spring-web/page/home.jsp.