Example usage for org.springframework.web.servlet.support RequestContext getContextPath

List of usage examples for org.springframework.web.servlet.support RequestContext getContextPath

Introduction

In this page you can find the example usage for org.springframework.web.servlet.support RequestContext getContextPath.

Prototype

public String getContextPath() 

Source Link

Document

Return the context path of the original request, that is, the path that indicates the current web application.

Usage

From source file:org.parancoe.web.tag.MarkPositionTag.java

@Override
protected final int doStartTagInternal() throws JspException, IOException {
    final HttpSession session = pageContext.getSession();
    ServletRequest request = pageContext.getRequest();
    final RequestContext requestContext = this.getRequestContext();
    final String uri = requestContext.getRequestUri();
    String contextPath = requestContext.getContextPath();
    final String queryString = requestContext.getQueryString();
    String url = "";
    if (uri.startsWith(contextPath)) {
        url = uri.substring(contextPath.length());
    } else {//from   w ww. ja va2s. c  om
        url = uri;
    }
    if (!StringUtils.isBlank(queryString)) {
        url = url + "?" + queryString;
    }
    if (useFullUri) {
        String port = "";
        if (request.getServerPort() != 80) {
            port = ":" + request.getServerPort();
        }
        url = request.getScheme() + "://" + request.getServerName() + port + requestContext.getContextPath()
                + url;
    }
    MarkPositionHelper.markPosition(session, pathId, url);
    return SKIP_BODY;
}