I access my Spring application right now as follows:
http://localhost:8080/my-app
In my JSPs I’d like to have access to my application root instead of hardcoding hyperlinks to the homepage as <a href="/my-app">. Is there some sort of variable that I can access in my jsps to point to the application root? Thanks
You can use
${pageContext.request.contextPath}. For example, to gethref = "/my-app/somePage", use:However, this approach doesn’t support URL rewriting required to maintain sessions in the case of disabled cookies. So, the better way to do it is JSTL’s
<c:url/>tag: