Example usage for javax.servlet.http HttpServletRequest getRequestURI

List of usage examples for javax.servlet.http HttpServletRequest getRequestURI

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getRequestURI.

Prototype

public String getRequestURI();

Source Link

Document

Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.

Usage

From source file:com.netflix.spinnaker.gate.interceptors.RequestLoggingInterceptor.java

private static String getRequestEndpoint(HttpServletRequest request) {
    String endpoint = request.getRequestURI();
    if (request.getQueryString() != null) {
        return endpoint + "?" + request.getQueryString();
    }/*from  w w  w. j  a  va  2  s.c o  m*/
    return endpoint;
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.authenticate.LogoutRedirector.java

/**
 * This must be called each time VitroHttpRequest checks to see whether a
 * page's restrictions are met, so we know which pages are restricted.
 * //from  w w w . ja  v a  2 s. c o  m
 * We might be content to just know the last restricted page, but that could
 * lead to problems if two pages are nested.
 */
public static void recordRestrictedPageUri(HttpServletRequest request) {
    String uri = request.getRequestURI();
    log.debug("Recording restricted URI: '" + uri + "'");
    getRestrictedPageUris(request).add(uri);
}

From source file:io.lavagna.web.security.SecurityFilter.java

private static String reqUriWithoutContextPath(HttpServletRequest request) {
    return request.getRequestURI().substring(request.getServletContext().getContextPath().length());
}

From source file:io.lavagna.web.security.SecurityFilter.java

private static boolean canApplyNoCachingHeaders(HttpServletRequest req) {
    String u = req.getRequestURI();
    return !("/".equals(u) || u.matches(".*\\.(css|gif|js|png|html|eot|svg|ttf|woff)$"));
}

From source file:com.manydesigns.elements.servlet.ServletUtils.java

/**
 * Returns the requested path, without the context path. E.g. webapp deployed under /foo, GET /foo/bar/baz?q=1&k=2,
 * getPath() returns /bar/baz./*w ww . j a  v a2  s . co  m*/
 * @param request the HTTP request
 * @return the path of the requested resource as a path internal to the webapp.
 */
public static String getPath(HttpServletRequest request) {
    String path = request.getRequestURI();
    String contextPath = request.getContextPath();
    if (path.startsWith(contextPath)) {
        path = path.substring(contextPath.length());
    }
    return path;
}

From source file:eu.europa.ejusticeportal.dss.demo.web.tags.RequestUrlRelativeUrlTagStrategy.java

/**
 * @param request/*from   ww w  .ja  v a 2 s .  co m*/
 *            the HTTP request
 * @return the request URL relative to the context root
 */
public static String getContextRootRelativeRequestURL(HttpServletRequest request) {
    return request.getRequestURI();
}

From source file:ke.alphacba.cms.core.util.RequestUtils.java

/**
 * ????Json??//from   w  ww.  ja  va 2 s .  c  om
 * 
 * @param request
 * @return
 */
public static boolean isAcceptJson(HttpServletRequest request) {
    return request.getRequestURI().contains(".json")
            || request.getHeader(CoreConstants.ACCEPT).indexOf(CoreConstants.APPLICATION_JSON) > -1;
}

From source file:ke.alphacba.cms.core.util.RequestUtils.java

/**
 * ??,?uri/*from ww w . j a va  2s  .  c  o  m*/
 * 
 * @param suffix
 * @return
 */
public static String getUriBody(HttpServletRequest request, String suffix) {
    return request.getRequestURI().replace(request.getContextPath() + "/", "").replace(suffix, "");
}

From source file:nl.dtls.fairdatapoint.api.controller.utils.LoggerUtils.java

/**
 * Log the request.//w  w w .  j  a  va  2  s  .c o  m
 * 
 * Log message pattern [Time\t IP\t requestMethod\t requestedURL]
 * @param logger    Class logger
 * @param request   Client request
 * @param response  Server response
 */
public static void logRequest(Logger logger, HttpServletRequest request, HttpServletResponse response) {
    ThreadContext.put("requestMethod", request.getMethod());
    ThreadContext.put("requestURI", request.getRequestURI());
    ThreadContext.put("requestProtocol", request.getProtocol());
    ThreadContext.put("responseStatus", String.valueOf(response.getStatus()));
    String contentLength = response.getHeader(HttpHeaders.CONTENT_LENGTH);
    ThreadContext.put("contentSize", contentLength);
    logger.log(Level.getLevel("API-REQUEST"), "");
}

From source file:nu.yona.server.rest.GlobalExceptionMapping.java

public static String buildRequestInfo(HttpServletRequest request) {
    String queryString = request.getQueryString();
    String url = StringUtils.isBlank(queryString) ? request.getRequestURI()
            : request.getRequestURI() + "?" + queryString;
    return MessageFormat.format("{0} on URL {1}", request.getMethod(), url);
}