One thing I am struggling with is creating a menu that highlights the current page when navigating through my site. For example, if I am on Page 1, I want the "Page 1" link in the menu to stand out. I have been attempting different methods found on Stack Overflow, but none seem to achieve the desired result.
req.contextPath: ${req.contextPath }<br/>
req.requestURL: ${req.requestURL }<br/>
pageContext.request.requestURL: ${pageContext.request.requestURL }<br/>
pageContext.request.requestURI: ${pageContext.request.requestURI }<br/>
pageContext.request.servletPath: ${pageContext.request.servletPath }<br/>
action name: ${com.opensymphony.xwork2.ActionContext.name }<br/>
action name 2: ${#context['struts.actionMapping'].name}<br/>
Unfortunately, here is what I am getting as output:
req.contextPath: /myContextRoot
req.requestURL: http://localhost:9080/myContextRoot/WEB-INF/app/layout/simpleLayout.jsp
pageContext.request.requestURL: http://localhost:9080/myContextRoot/WEB-INF/app/layout/simpleLayout.jsp
pageContext.request.requestURI: /myContextRoot/WEB-INF/app/layout/simpleLayout.jsp
pageContext.request.servletPath: /WEB-INF/app/layout/simpleLayout.jsp
action name:
action name 2:
I am looking for a solution where I can achieve the following functionality:
<c:choose>
<c:when test="${pageContext.request.requestURI == 'page1.action')}">
<c:set var="page1ButtonClass" value="class=\"active\""/>
</c:when>
</c:choose>
Just to provide some context, our setup involves Struts 2.3.8.