List of usage examples for org.springframework.security.web.servletapi SecurityContextHolderAwareRequestWrapper getContextPath
@Override
public String getContextPath()
From source file:org.ngrinder.common.util.HttpContainerContext.java
/** * Get current container nGrinder context base path. * <p/>/*from www. j a v a 2 s . c o m*/ * E.g) if user requests http://hostname:port/context_path/realurl, This * will return http://hostname:port/context_path * <p/> * In case of providing "http.url" property in system.properties file, this * method will return pre-set value. * * @return ngrinder context base path on http request. */ public String getCurrentContextUrlFromUserRequest() { String httpUrl = StringUtils.trimToEmpty(config.getControllerProperties().getProperty(PROP_CONTROLLER_URL)); // if provided if (StringUtils.isNotBlank(httpUrl)) { return httpUrl; } // if empty SecurityContextHolderAwareRequestWrapper request = cast( RequestContextHolder.currentRequestAttributes().resolveReference("request")); int serverPort = request.getServerPort(); // If it's http default port it will ignore the port part. // However, if ngrinder is provided in HTTPS.. it can be a problem. // FIXME : Later fix above. String portString = (serverPort == DEFAULT_WEB_PORT) ? StringUtils.EMPTY : ":" + serverPort; return httpUrl + request.getScheme() + "://" + request.getServerName() + portString + request.getContextPath(); }