List of usage examples for javax.servlet.http HttpServletRequest getRequestURI
public String getRequestURI();
From source file:com.soolr.core.web.Servlets.java
public static String getHost(HttpServletRequest request) { String requestURL = request.getRequestURL().toString(); String requestURI = request.getRequestURI(); String host = StringUtils.substringBefore(requestURL, requestURI); return host;/*from ww w .ja v a 2s . c o m*/ }
From source file:org.artifactory.webapp.servlet.RequestUtils.java
@SuppressWarnings({ "IfMayBeConditional" }) public static String getContextPrefix(HttpServletRequest request) { String contextPrefix;/*from www.ja v a 2 s .co m*/ String requestUri = request.getRequestURI(); int contextPrefixEndIdx = requestUri.indexOf('/', 1); if (contextPrefixEndIdx > 0) { contextPrefix = requestUri.substring(1, contextPrefixEndIdx); } else { contextPrefix = ""; } return contextPrefix; }
From source file:com.soolr.core.web.Servlets.java
public static String getBasePath(HttpServletRequest request) { String requestURL = request.getRequestURL().toString(); String requestURI = request.getRequestURI(); String host = StringUtils.substringBeforeLast(requestURL, requestURI); String contextPath = request.getContextPath(); return StringUtils.removeEnd(host + contextPath, "/"); }
From source file:com.wavemaker.runtime.server.ServerUtils.java
public static String getFileName(HttpServletRequest request) { String uri = request.getRequestURI(); if (-1 != uri.lastIndexOf('/')) { uri = uri.substring(uri.lastIndexOf('/') + 1); }//from w w w . j av a2s. c o m return uri; }
From source file:com.wavemaker.runtime.server.ServerUtils.java
public static String getDirectory(HttpServletRequest request) { String uri = request.getRequestURI(); if (-1 != uri.lastIndexOf('/')) { uri = uri.substring(0, uri.lastIndexOf('/')); }// w w w .j a va 2 s . c o m if (0 == "".compareTo(uri)) { uri = "/"; } return uri; }
From source file:edu.duke.cabig.c3pr.utils.web.AuditInfoFilter.java
/** * @param httpReq//from w w w.j av a2s .c o m */ public static void setAuditInfo(HttpServletRequest httpReq) { String userName = SecurityUtils.getUserName(); if (!StringUtils.isBlank(userName)) { log.debug("setting audit info for " + userName); gov.nih.nci.cabig.ctms.audit.DataAuditInfo .setLocal(new gov.nih.nci.cabig.ctms.audit.domain.DataAuditInfo(userName, httpReq.getRemoteAddr(), new Date(), httpReq.getRequestURI())); } else { log.debug("no authentication found in SecurityContext. Skipping audit info setup"); } }
From source file:de.micromata.genome.logging.LogRequestDumpAttribute.java
/** * Gen http request dump.//from ww w . j ava 2s.c o m * * @param req the req * @return the string */ @SuppressWarnings("unchecked") public static String genHttpRequestDump(HttpServletRequest req) { StringBuilder sb = new StringBuilder(); sb.append("method: ").append(req.getMethod()).append('\n')// .append("requestURL: ").append(req.getRequestURL()).append('\n')// .append("servletPath: ").append(req.getServletPath()).append('\n')// .append("requestURI: ").append(req.getRequestURI()).append('\n') // .append("queryString: ").append(req.getQueryString()).append('\n') // .append("pathInfo: ").append(req.getPathInfo()).append('\n')// .append("contextPath: ").append(req.getContextPath()).append('\n') // .append("characterEncoding: ").append(req.getCharacterEncoding()).append('\n') // .append("localName: ").append(req.getLocalName()).append('\n') // .append("contentLength: ").append(req.getContentLength()).append('\n') // ; sb.append("Header:\n"); for (Enumeration<String> en = req.getHeaderNames(); en.hasMoreElements();) { String hn = en.nextElement(); sb.append(" ").append(hn).append(": ").append(req.getHeader(hn)).append("\n"); } sb.append("Attr: \n"); Enumeration en = req.getAttributeNames(); for (; en.hasMoreElements();) { String k = (String) en.nextElement(); Object v = req.getAttribute(k); sb.append(" ").append(k).append(": ").append(Objects.toString(v, StringUtils.EMPTY)).append('\n'); } return sb.toString(); }
From source file:gov.nih.nci.caintegrator.web.SessionHelper.java
private static String getRequestBaseUrl(HttpServletRequest request) { String requestUri = request.getRequestURI(); String requestUrl = request.getRequestURL().toString(); return requestUrl.substring(0, requestUrl.length() - requestUri.length()); }
From source file:org.artifactory.webapp.servlet.RequestUtils.java
/** * Returns the un-decoded servlet path from the request * * @param req The received request//from w w w . j a va 2s .co m * @return String - Servlet path */ public static String getServletPathFromRequest(HttpServletRequest req) { String contextPath = req.getContextPath(); if (StringUtils.isBlank(contextPath)) { return req.getRequestURI(); } return req.getRequestURI().substring(contextPath.length()); }
From source file:info.magnolia.cms.beans.config.MIMEMapping.java
/** * Get MIME type String./*from w w w. ja v a 2 s. c o m*/ * @param request * @return MIME type */ public static String getMIMEType(HttpServletRequest request) { String extension = (String) request.getAttribute(Aggregator.EXTENSION); if (StringUtils.isEmpty(extension)) { // the . could be in the middle of the url extension = StringUtils.substringAfterLast(request.getRequestURI(), "/"); extension = StringUtils.substringAfterLast(extension, "."); //$NON-NLS-1$ if (StringUtils.isEmpty(extension)) { extension = Server.getDefaultExtension(); } } String mimeType = getMIMEType(extension); if (mimeType == null && StringUtils.isNotEmpty(extension)) { log.info("Cannot find MIME type for extension \"" + extension + "\""); //$NON-NLS-1$ //$NON-NLS-2$ mimeType = ((MIMEMappingItem) MIMEMapping.cachedContent.get(Server.getDefaultExtension())).mime; } return mimeType; }