Example usage for javax.servlet.http HttpServletRequest getQueryString

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

Introduction

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

Prototype

public String getQueryString();

Source Link

Document

Returns the query string that is contained in the request URL after the path.

Usage

From source file:edu.pitt.dbmi.ccd.anno.links.ResourceLinks.java

default Link getRequestLink(HttpServletRequest request) {
    final StringBuffer url = request.getRequestURL();
    final String query = request.getQueryString();
    if (query == null) {
        return new Link(url.toString(), Link.REL_SELF);
    } else {//  w ww. ja  v a  2  s  .c  o  m
        return new Link(url.append("?").append(query).toString(), Link.REL_SELF);
    }
}

From source file:com.acc.storefront.filters.RequestLoggerFilter.java

protected String buildRequestDetails(final HttpServletRequest request) {
    String queryString = request.getQueryString();
    if (queryString == null) {
        queryString = "";
    }/*from w w w.  ja  v a2 s .  c  o m*/

    final String requestUri = request.getRequestURI();

    final String securePrefix = request.isSecure() ? "s" : " ";
    final String methodPrefix = request.getMethod().substring(0, 1);

    return securePrefix + methodPrefix + " [" + requestUri + "] [" + queryString + "] ";
}

From source file:org.focusns.common.web.performance.MonitorFilter.java

private String getRequestDescription(HttpServletRequest request) {
    StringBuilder sb = new StringBuilder(request.getRequestURI());
    if (StringUtils.hasText(request.getQueryString())) {
        sb.append("?").append(request.getQueryString());
    }//from  ww w  . ja v  a 2  s  .com
    sb.append(" [").append(request.getMethod()).append("]");
    return sb.toString();
}

From source file:nl.surfnet.coin.shared.log.ApiCallLogContextListener.java

@Override
public void requestInitialized(ServletRequestEvent requestEvent) {
    ApiCallLog apiCallLog = new ApiCallLog();
    HttpServletRequest request = (HttpServletRequest) requestEvent.getServletRequest();
    String queryString = request.getQueryString();
    StringBuffer requestURL = request.getRequestURL();
    if (StringUtils.hasText(queryString)) {
        requestURL.append("?").append(queryString);
    }/*from www  . j  a  v  a 2 s  .  co  m*/
    try {
        apiCallLog.setResourceUrl(URLEncoder.encode(requestURL.toString(), "utf-8"));
        apiCallLog.setIpAddress(request.getRemoteAddr());
    } catch (UnsupportedEncodingException e) {
        // will never happen as utf-8 is the encoding
    }
    apiCallLogHolder.set(apiCallLog);
}

From source file:com.pamarin.income.security.JsfRedirectStrategy.java

private String getRequestUrl(HttpServletRequest request) {
    StringBuffer requestURL = request.getRequestURL();

    String queryString = request.getQueryString();
    if (StringUtils.hasText(queryString)) {
        requestURL.append("?").append(queryString);
    }/*from  w  w  w .  j av  a2 s . com*/

    return requestURL.toString();
}

From source file:foo.domaintest.action.RequestModule.java

/** Provides the query string of the request URL. */
@Provides//from   w w  w  .j a v  a  2 s. c o m
@RequestData("queryString")
String provideQueryString(HttpServletRequest request) {
    return nullToEmpty(request.getQueryString());
}

From source file:eu.openanalytics.shinyproxy.controllers.AppController.java

private String buildContainerPath(String mapping, HttpServletRequest request) {
    if (mapping == null)
        return "";

    String queryString = request.getQueryString();
    queryString = (queryString == null) ? "" : "?" + queryString;

    String containerPath = getContextPath() + mapping + environment.getProperty("proxy.landing-page", "/")
            + queryString;//from w  ww .  j  ava2  s  .  c om
    return containerPath;
}

From source file:snoopware.api.UserGridProxyServlet.java

/**
 * Override to add Authorization to requests that need it.
 * @param req//w w w .j  a v  a2 s . c om
 * @param proxyReq
 */
@Override
protected void copyRequestHeaders(HttpServletRequest req, HttpRequest proxyReq) {
    super.copyRequestHeaders(req, proxyReq);

    boolean hasAccessToken = req.getQueryString() == null ? false
            : req.getQueryString().contains("access_token=");

    if (!hasAccessToken && ("POST".equalsIgnoreCase(req.getMethod()) || "GET".equalsIgnoreCase(req.getMethod()))
            && req.getPathInfo().contains("/" + applicationName + "/user")) {

        String header = "Bearer " + client.getAccessToken();
        proxyReq.setHeader("Authorization", header);
        log.debug("Added header {} to URL {}", header, req.getRequestURL().toString());
    } else {
        log.debug("Not adding header to request with " + req.getRequestURL().toString());
    }
}

From source file:io.soabase.web.filters.LanguageFilter.java

@Override
public String getLanguageCode(HttpServletRequest request) {
    return getLanguageCode(request.getQueryString(), getCookie(request));
}

From source file:org.consultjr.mvc.core.components.ApplicationInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    String queryString = request.getQueryString();
    String uri = request.getRequestURI();
    StringBuffer url = request.getRequestURL();
    HttpSession session = this.getSession(request);
    Enumeration attributes = session.getAttributeNames();
    Map<String, Object> sessionAttributes = new HashMap<>();

    logger.debug("URL: {}", url);
    logger.debug("URI: {}", uri);
    logger.debug("QUERY STRING: {}", queryString);

    logger.debug("Handler Object: {}", handler);

    while (attributes.hasMoreElements()) {
        String name = (String) attributes.nextElement();

        sessionAttributes.put(name, session.getAttribute(name));
    }/*ww w.  j a  v  a 2s  . c o m*/

    logger.debug("Session: {}", sessionAttributes);

    return true;
}