snippetjournal

– notes, snippet codes, and my journal

Archive for December 2014

Get Context Url from Java Servlet

leave a comment »

Get Context Url from Java Servlet


<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="req" value="${pageContext.request}" />
<c:set var="url">${req.requestURL}</c:set>
<c:set var="uri" value="${req.requestURI}" />
<c:set var="urlContext" value="${fn:substring(url, 0, fn:length(url) - fn:length(pageContext.request.requestURI))}${pageContext.request.contextPath}/" />

Written by snippetjournal

December 31, 2014 at 2:55 am

Posted in Programming

Tagged with ,