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:com.blackducksoftware.integration.hub.bamboo.HubBambooServlet.java

private URI getUri(final HttpServletRequest request) {
    final StringBuffer builder = request.getRequestURL();
    if (request.getQueryString() != null) {
        builder.append("?");
        builder.append(request.getQueryString());
    }/*  w  ww.j ava 2 s  .c  o  m*/
    return URI.create(builder.toString());
}

From source file:io.kamax.mxisd.controller.profile.v1.ProfileController.java

private String resolveProxyUrl(HttpServletRequest req) {
    URI target = URI.create(req.getRequestURL().toString()
            + (Objects.isNull(req.getQueryString()) ? "" : "?" + req.getQueryString()));
    URIBuilder builder = dns.transform(target);
    String urlToLogin = builder.toString();
    log.info("Proxy resolution: {} to {}", target.toString(), urlToLogin);
    return urlToLogin;
}

From source file:com.lm.lic.manager.util.GenUtil.java

/**
 * @param request/*from   w w  w . ja va  2  s .  c o  m*/
 */
@SuppressWarnings("unchecked")
public static void debugRequestParams(HttpServletRequest request) {
    Enumeration<String> en = request.getParameterNames();
    while (en.hasMoreElements()) {
        String p = en.nextElement();
        String v = request.getParameter(p);
        System.out.println("\nPARAM: " + p);
        System.out.println("VALUE: " + v);
    }

    en = request.getHeaderNames();
    while (en.hasMoreElements()) {
        String p = en.nextElement();
        String v = request.getParameter(p);
        System.out.println("\nPHEADER: " + p);
        System.out.println("VALUE: " + v);
    }

    String qs = request.getQueryString();
    System.out.println("QueryString: " + qs);
    String method = request.getMethod();
    System.out.println("Method: " + method);
}

From source file:com.apress.progwt.server.web.controllers.MyListController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest req, HttpServletResponse arg1)
        throws Exception {

    log.debug("SERVLET PATH: " + req.getServletPath() + " " + req.getPathInfo() + " " + req.getQueryString());

    Map<String, Object> model = getDefaultModel(req);

    ModelAndView mav = getMav();/*from   w  ww.j a  v a 2 s . c  o  m*/
    mav.addAllObjects(model);
    return mav;
}

From source file:eu.delving.services.controller.SolrProxyController.java

@RequestMapping("/api/solr/select")
public void searchController(HttpServletRequest request, HttpServletResponse response) throws Exception {
    final String solrQueryString = request.getQueryString();
    HttpMethod method = new GetMethod(
            String.format("%s/select?%s", ThemeFilter.getTheme().getSolrSelectUrl(), solrQueryString));
    httpClient.executeMethod(method);/*from w  ww  .ja va 2s  .  c o  m*/
    Boolean getAsStream = false;
    for (Header header : method.getResponseHeaders()) {
        if (header.getName().equalsIgnoreCase("content-type")) {
            final String contentType = method.getResponseHeader("Content-Type").getValue();
            response.setContentType(contentType);
            response.setHeader(header.getName(), header.getValue());
            if (contentType.equalsIgnoreCase("application/octet-stream")) {
                getAsStream = true;
            }
        } else if (header.getName().equalsIgnoreCase("server")) {
            //ignore
        } else {
            response.setHeader(header.getName(), header.getValue());
        }
    }
    response.setCharacterEncoding("UTF-8");
    if (getAsStream) {
        OutputStream out = response.getOutputStream();
        try {
            IOUtils.copy(method.getResponseBodyAsStream(), out);
        } finally {
            out.close();
        }
    } else {
        response.getWriter().write(method.getResponseBodyAsString()); //todo add response from SolrProxy here
        response.getWriter().close();
    }
}

From source file:org.valens.bamboo.servlets.AdminServlet.java

private URI getUri(HttpServletRequest request) {
    StringBuffer builder = request.getRequestURL();
    if (request.getQueryString() != null) {
        builder.append("?");
        builder.append(request.getQueryString());
    }//w  w w  . j ava  2s. co  m
    return URI.create(builder.toString());
}

From source file:es.itecban.deployment.executionmanager.web.controller.UnitInverseDependenciesController.java

private String getXMLDependencyGraphURL(DeploymentUnitType unit, HttpServletRequest request) throws Exception {
    String file = request.getRequestURI();
    if (request.getQueryString() != null) {
        file += '?' + request.getQueryString() + "&justGraph=true";
    }/*www  .  ja  v  a 2  s.c  om*/
    URL reconstructedURL = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), file);
    return reconstructedURL.toString();
}

From source file:org.apache.hadoop.gateway.dispatch.HttpClientDispatchTest.java

@Test
public void testCallToSecureClusterWithDelegationTpken() throws URISyntaxException, IOException {
    System.setProperty(GatewayConfig.HADOOP_KERBEROS_SECURED, "true");
    HttpClientDispatch httpClientDispatch = new HttpClientDispatch();
    ServletInputStream inputStream = EasyMock.createNiceMock(ServletInputStream.class);
    HttpServletRequest inboundRequest = EasyMock.createNiceMock(HttpServletRequest.class);
    EasyMock.expect(inboundRequest.getQueryString()).andReturn("delegation=123").anyTimes();
    EasyMock.expect(inboundRequest.getInputStream()).andReturn(inputStream).anyTimes();
    EasyMock.replay(inboundRequest);/*from  w w  w.j  a  v  a  2 s .  c o m*/
    HttpEntity httpEntity = httpClientDispatch.createRequestEntity(inboundRequest);
    System.setProperty(GatewayConfig.HADOOP_KERBEROS_SECURED, "false");
    assertFalse("buffering in the presence of delegation token",
            (httpEntity instanceof CappedBufferHttpEntity));
}

From source file:io.seldon.api.handler.ApiHandlerExceptionResolver.java

@Override
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response,
        Object handler, Exception ex) {
    String requestURI = request.getRequestURI();
    String queryString = request.getQueryString();
    logger.error("Uncaught exception: " + ex.getMessage() + " for " + requestURI + " with query " + queryString,
            ex);/*from   w w w .j a v  a  2  s . c  om*/
    return super.doResolveException(request, response, handler, ex);
}

From source file:org.apache.hadoop.gateway.dispatch.HttpClientDispatchTest.java

@Test
public void testCallToSecureClusterWithoutDelegationTpken() throws URISyntaxException, IOException {
    System.setProperty(GatewayConfig.HADOOP_KERBEROS_SECURED, "true");
    HttpClientDispatch httpClientDispatch = new HttpClientDispatch();
    httpClientDispatch.setReplayBufferSize(10);
    ServletInputStream inputStream = EasyMock.createNiceMock(ServletInputStream.class);
    HttpServletRequest inboundRequest = EasyMock.createNiceMock(HttpServletRequest.class);
    EasyMock.expect(inboundRequest.getQueryString()).andReturn("a=123").anyTimes();
    EasyMock.expect(inboundRequest.getInputStream()).andReturn(inputStream).anyTimes();
    EasyMock.replay(inboundRequest);/*from w ww .j a  v a  2 s. co m*/
    HttpEntity httpEntity = httpClientDispatch.createRequestEntity(inboundRequest);
    System.setProperty(GatewayConfig.HADOOP_KERBEROS_SECURED, "false");
    assertTrue("not buffering in the absence of delegation token",
            (httpEntity instanceof CappedBufferHttpEntity));
}