Kamil Janowski
Kamil Janowski

Reputation: 2025

Getting context path in a tag library

is it possible to get the context path in a class extending SimpleTagSupport? or is it actually necessary to pass it as a parameter to my tag?

Upvotes: 0

Views: 1670

Answers (2)

Khalid
Khalid

Reputation: 111

Try this :

ServletContext servletContext = ((PageContext) getJspContext()).getServletContext();

String appContext = servletContext.getContextPath();

Upvotes: 2

Larry.Z
Larry.Z

Reputation: 3724

I hope this will help you. In jsp view files

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

Upvotes: 0

Related Questions