Get context Path Using JSTL

Get context Path Using JSTL explains about how to get context path inside a JSP page

pageContext is an implicit object available in JSP, so it is very easy to get the contextPath using JSTL EL Expression

You can access the request scoped varaibles in following different ways

Below code is equivalent to <%=request.getContextPath()%> in JSTL?

<c:out value="${pageContext.request.contextPath}"/>

you can see the below a complete example about accessing contextpath in JSTL

Required Libraries

You need to download

  1. Tomcat 9
  2. JSTL 1.2

Following jar must be in classpath

  1. jstl-1.2.jar

Get context Path Using JSTL

<%@ taglib uri="" prefix="c"%>

<!-- Get context path using JSTL -->

<c:out value="${pageContext.servletContext.contextPath}" />



Your email address will not be published. Required fields are marked *