Example usage for javax.servlet.http HttpServletRequest getRequestURL

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

Introduction

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

Prototype

public StringBuffer getRequestURL();

Source Link

Document

Reconstructs the URL the client used to make the request.

Usage

From source file:com.comcast.cdn.traffic_control.traffic_router.api.util.APIAccessRecord.java

private static String getUrl(final HttpServletRequest request) {
    final StringBuffer buf = request.getRequestURL();
    if (request.getQueryString() != null) {
        buf.append('?');
        buf.append(request.getQueryString());
    }/*from   w  w w.  j a v a2  s  . c  om*/
    return buf.toString();
}

From source file:edu.txstate.dmlab.clusteringwiki.web.BaseController.java

/**
 * Check if request is coming from local server.  Some resources
 * (ex: NYTimes data set) cannot be made available publically
 * @return//from w  w  w .  j  a v a  2 s.  c om
 */
public static boolean isLocalRequest(HttpServletRequest request) {
    return request.getRequestURL().indexOf(":8080") > -1;
}

From source file:com.doculibre.constellio.utils.WebappUtils.java

public static URL getContextPathURL(HttpServletRequest httpRequest) {
    StringBuffer requestURL = httpRequest.getRequestURL();
    String contextPath = httpRequest.getContextPath();
    String requestURI = httpRequest.getRequestURI();
    String beforeContextPath = StringUtils.substringBefore(requestURL.toString(), requestURI);
    try {/*from  w  w  w  . ja  v  a  2s .c o m*/
        return new URL(beforeContextPath + contextPath);
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.google.step2.Step2.java

/**
 * Returns the URL of an incoming HTTP request, including query parameters.
 * @param req the incoming HTTP request/* www. j  a  va  2s  .  c o  m*/
 * @return the URL that is represented by this HTTP request
 */
public static String getUrlWithQueryString(HttpServletRequest req) {
    StringBuffer receivingUrl = req.getRequestURL();
    String queryString = req.getQueryString();
    if (queryString != null && queryString.length() > 0) {
        receivingUrl.append("?").append(req.getQueryString());
    }
    log.info(receivingUrl.toString());
    return receivingUrl.toString();
}

From source file:com.app.framework.web.mvc.ActionMap.java

public static String getFullURL(HttpServletRequest request) {
    StringBuffer requestURL = request.getRequestURL();
    String queryString = request.getQueryString();

    if (queryString == null) {
        return requestURL.toString();
    } else {/*ww  w  .j  av  a 2 s .c  o  m*/
        return requestURL.append('?').append(queryString).toString();
    }
}

From source file:com.gst.infrastructure.security.data.PlatformRequestLog.java

public static PlatformRequestLog from(final StopWatch task, final HttpServletRequest request)
        throws IOException {
    final String requestUrl = request.getRequestURL().toString();

    final Map<String, String[]> parameters = new HashMap<>(request.getParameterMap());
    parameters.remove("password");
    parameters.remove("_");

    return new PlatformRequestLog(task.getStartTime(), task.getTime(), request.getMethod(), requestUrl,
            parameters);/*  w  ww .jav a  2  s. c  o  m*/
}

From source file:com.tang.util.RequestBeanKit.java

public static String getUrl(HttpServletRequest request) {
    String url = request.getRequestURL().toString();
    String parmas = request.getQueryString();
    if (StrKit.notBlank(parmas)) {
        url = url + "?" + parmas;
    }//from   w  ww.j  av  a 2  s  . c  om
    return url;
}

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

private static boolean isOverHttps(HttpServletRequest req) {
    return req.isSecure() || req.getRequestURL().toString().startsWith("https://")
            || StringUtils.equals("https", req.getHeader("X-Forwarded-Proto"));
}

From source file:eu.europeana.core.util.web.ControllerUtil.java

public static String getServletUrl(HttpServletRequest request) {
    String url = request.getRequestURL().toString();
    int index = url.indexOf(request.getServerName());
    url = url.substring(0, index) + request.getServerName() + ":" + request.getServerPort()
            + request.getContextPath();/*from w  w  w .  j  a  va  2 s  . c  o m*/
    return url;
}

From source file:eu.europeana.core.util.web.ControllerUtil.java

public static String getFullServletUrl(HttpServletRequest request) {
    String url = request.getRequestURL().toString();
    int index = url.indexOf(request.getServerName());
    url = url.substring(0, index) + request.getServerName() + ":" + request.getServerPort()
            + request.getRequestURI();//  w  w  w  .  j  ava2 s .co  m
    return url;
}