List of usage examples for javax.servlet.http HttpServletRequest getContextPath
public String getContextPath();
From source file:com.leixl.easyframework.web.CookieUtils.java
/** * ?cookie//from w w w . j a va 2s .c om * * @param request * @param response * @param name * @param domain */ public static void cancleCookie(HttpServletRequest request, HttpServletResponse response, String name, String domain) { Cookie cookie = new Cookie(name, ""); cookie.setMaxAge(0); String ctx = request.getContextPath(); cookie.setPath(StringUtils.isBlank(ctx) ? "/" : ctx); if (StringUtils.isNotBlank(domain)) { cookie.setDomain(domain); } response.addCookie(cookie); }
From source file:com.eastcom.baseframe.web.common.utils.Servlets.java
public static String getContextPath(HttpServletRequest request) { return request.getContextPath(); }
From source file:com.yuga.common.web.Servlets.java
/** * ??//from w w w . j av a 2s .c om * @param request * @return */ public static String getContextString(HttpServletRequest request) { String contextStr = request.getContextPath(); String requestURL = request.getRequestURL().toString(); String url = requestURL.substring(0, requestURL.indexOf(contextStr)) + contextStr; return url; }
From source file:info.magnolia.module.servletsanity.support.ServletAssert.java
public static void assertRequestUri(HttpServletRequest request, String expected) throws IOException { expected = request.getContextPath() + expected; if (!request.getRequestURI().equals(expected)) { append("ERROR RequestURI is [" + request.getRequestURI() + "] expected it to be [" + expected + "]"); } else {/*from w w w . j av a 2s.co m*/ append("PASSED RequestURI is correct"); } }
From source file:org.apache.archiva.redback.integration.util.AutoLoginCookies.java
private static String getWebappContext(HttpServletRequest httpRequest) { // Calculate the webapp context. String webappContext = httpRequest.getContextPath(); if (StringUtils.isEmpty(webappContext)) { // Still empty? means you are a root context. webappContext = "/"; }/*w ww . j av a2 s .c o m*/ return webappContext; }
From source file:your.microservice.core.util.YourServletUriComponentsBuilder.java
/** * Prepare a builder from the host, port, scheme, and context path of * an HttpServletRequest./*from w w w .j a v a 2 s . c o m*/ * @param request request to build path from * @return the component builder created from the path */ public static YourServletUriComponentsBuilder fromContextPath(HttpServletRequest request) { YourServletUriComponentsBuilder builder = fromRequest(request); builder.replacePath(request.getContextPath()); builder.replaceQuery(null); return builder; }
From source file:com.beginner.core.utils.ProjectUtil.java
/** * ???(?????)// w w w. jav a 2s . c o m */ public static String path() { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) .getRequest(); return request.getContextPath(); }
From source file:com.yiji.openapi.sdk.util.Servlets.java
/** * ?URL//ww w . j ava 2 s. c om * * @param request * @return */ public static String getRequestPath(HttpServletRequest request) { return StringUtils.substringAfter(request.getRequestURI(), request.getContextPath()); }
From source file:net.sensemaker.snappy.SnappyUtil.java
public static void injectScript(FacesContext context, String scriptUri, String resourcePath) throws IOException { HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest(); String contextPath = request.getContextPath(); Map attributes = new HashMap(); attributes.put("type", "text/javascript"); attributes.put("src", contextPath + resourcePath + scriptUri); addHeaderTag(context, "script", attributes); }
From source file:com.beginner.core.utils.ProjectUtil.java
/** * ?/*from w w w . ja v a 2s.c o m*/ * @return String http://ip?:??/??/ */ public static String basePath() { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) .getRequest(); String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; return basePath; }