Can someone explain what this page Context.request.contextPath does?

can someone explain what thisContext.request.contextPath page will do? It would be helpful if you would give an example. Thanks in advance.

+4
source share
1 answer

${pageContext.request.contextPath}is an EL expression equivalent to a JSP expression <%= request.getContextPath() %>.

It is recommended to use ${pageContext.request.contextPath}instead of hard coding your context path.

eg. <a href="${pageContext.request.contextPath}/info/page.html">Link</a>better than<a href="http://abc.xyz.com/info/page.html">Link</a>

+8
source