I want to retrieve root path of webapplication, then I want to append link to root path. I tried request.context but it returns \"http://localhost:8080/webapp/web-inf\".
You can also use
<c:url>
jstl tag. It will add the context path for you.
<%=request.getContextPath()%>
will give you the rootpath of your application so in your case it will be http://localhost:8080/webapp
As per comment:
<%=request.getContextPath()%>/help/page/help.htm
will give you your page
I believe you can use the getRealPath() method of the ServletContext.
You can use pageContext.request.contextPath
${pageContext.request.contextPath}
So you can use,
<a href="${pageContext.request.contextPath}${helpPath}" target="_blank">name</a>
But the better way is to set the base href to this path and then use the path as it is.
<head>
<base href="${pageContext.request.contextPath}">
</head>
<body>
<a href="${helpPath}" target="_blank">name</a>
</body>
<%=request.getContextPath()%>
will give /webapp
So your link should look like :
<a href="<%=request.getContextPath()%>${helpPath}" target="_blank">name</a>