-
Notifications
You must be signed in to change notification settings - Fork 0
jsps
Eric F. Alsheimer edited this page Jan 24, 2018
·
3 revisions
JSPs aren't really Spring but I will be detailing them in a Spring context without much concern for differentiating pro-Spring behavior from stock behavior, hence the blanket "Spring" moniker.
You can get the base URL inside a JSP by using pageContext.request.contextPath.
...
<%@ taglib prefix="c" url="http://java.sun.com/jsp/jstl/core" %>
...
<c:set var="contextPath" value="${pageContext.request.contextPath}" />
<a href="${contextPath}/services">List Organizations by Service</a>
...pageContext is an implicit object in Spring that has all the information related to the page. The request information is stored in the request method. Finally the contextPath is the place the user contacted.