Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can anyone explain what this pageContext.request.contextPath does? [duplicate]

can anyone explain what will this pageContext.request.contextPath does?it would be helpful if you give an example.Thanks in advance.

like image 475
user3931813 Avatar asked Feb 11 '23 00:02

user3931813


1 Answers

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

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

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

like image 174
Kamlakant Shukla Avatar answered Feb 13 '23 12:02

Kamlakant Shukla