web/src/main/java/org/springframework/security/web/util/UrlUtils.java
private static String buildRequestUrl(String servletPath, String requestURI,
			String contextPath, String pathInfo, String queryString) {

		StringBuilder url = new StringBuilder();

		if (servletPath != null) {
			url.append(servletPath);
			if (pathInfo != null) {
				url.append(pathInfo);
			}
		}
		else {
			url.append(requestURI.substring(contextPath.length()));
		}

		if (queryString != null) {
			url.append("?").append(queryString);
		}

		return url.toString();
	}
private static String buildRequestUrl(String servletPath, String requestURI,
			String contextPath, String pathInfo, String queryString) {

		StringBuilder url = new StringBuilder();

		if (servletPath != null) {
			url.append(servletPath);
			if (pathInfo != null) {
				url.append(pathInfo);
			}
		}
		else {
			url.append(requestURI.substring(contextPath.length()));
		}

		if (queryString != null) {
			url.append("?").append(queryString);
		}

		return url.toString();
	}
Obtains the web application-specific fragment of the URL.