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:net.acesinc.convergentui.content.ContentFetchCommand.java

@Override
protected ContentResponse run() throws Exception {
    log.debug("Getting live content from [ " + location + " ]");
    try {// ww  w .  j a va 2  s  .c om
        HttpServletRequest request = requestContext.getRequest();
        MultiValueMap<String, String> headers = this.helper.buildZuulRequestHeaders(request);

        if (request.getQueryString() != null && !request.getQueryString().isEmpty()) {
            MultiValueMap<String, String> params = this.helper.buildZuulRequestQueryParams(request);
        }

        HttpHeaders requestHeaders = new HttpHeaders();
        for (String key : headers.keySet()) {
            for (String s : headers.get(key)) {
                requestHeaders.add(key, s);
            }
        }
        HttpEntity requestEntity = new HttpEntity(null, requestHeaders);

        ResponseEntity<Object> exchange = this.restTemplate.exchange(location, HttpMethod.GET, requestEntity,
                Object.class);

        ContentResponse response = new ContentResponse();
        response.setContent(exchange.getBody());
        response.setContentType(exchange.getHeaders().getContentType());
        response.setError(false);

        return response;
    } catch (Exception e) {
        log.debug("Error fetching live content from [ " + location + " ]", e);
        throw e;
    }
}

From source file:edu.du.penrose.systems.fedoraProxy.web.bus.RelsExt_risearch.java

/**
 * @param webSite  (path variable) used to retrieve the webSite collection pid from the webSiteCollection.properties file, if not found a response status of 404 is returned.
 * <br>/*from w w  w .  j a va2s  .  c  o m*/
 * @param request the original http request object.
 * @param response the http response sent back to the browser.
 * @throws Exception
 */
@RequestMapping(method = RequestMethod.GET)
public final void proxyCall(@PathVariable String webSite, HttpServletRequest request,
        HttpServletResponse response) throws Exception // MUST BE type Exception for annotation to work!
{

    this.performProxyCall(webSite, null, RELEXT_OBJECT_CMD + request.getQueryString(), response);

}

From source file:com.oauth.servlet.AuthorizationCallbackServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    try {//  w  w w.ja v a2s. co  m
        System.err.println(req.getQueryString());
        System.err.println(req.getRequestURI());
        String token = null;
        String responseBody = null;
        if (req.getParameter("code") != null) {
            HttpClient httpclient = new DefaultHttpClient();
            String authCode = req.getParameter("code");
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            try {
                if (req.getRequestURI().indexOf("git") > 0) {
                    HttpGet httpget = new HttpGet(client.getAccessTokenUrl(authCode));

                    responseBody = httpclient.execute(httpget, responseHandler);
                    int accessTokenStartIndex = responseBody.indexOf("access_token=")
                            + "access_token=".length();
                    token = responseBody.substring(accessTokenStartIndex,
                            responseBody.indexOf("&", accessTokenStartIndex));

                } else if (req.getRequestURI().indexOf("isam") > 0) {
                    System.err.println(iSAMClient.getAccessTokenUrl());
                    HttpPost httpPost = new HttpPost(iSAMClient.getAccessTokenUrl());
                    httpPost.addHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");

                    System.err.println("Post Params--------");
                    for (Iterator<NameValuePair> postParamIter = iSAMClient.getPostParams(authCode)
                            .iterator(); postParamIter.hasNext();) {
                        NameValuePair postParam = postParamIter.next();
                        System.err.println(postParam.getName() + "=" + postParam.getValue());
                    }
                    httpPost.setEntity(new UrlEncodedFormEntity(iSAMClient.getPostParams(authCode)));
                    System.err.println("Post Params--------");
                    responseBody = httpclient.execute(httpPost, responseHandler);
                    token = parseJsonString(responseBody);
                } else {
                    resp.sendError(HttpStatus.SC_FORBIDDEN);
                }
                System.err.println(responseBody);
                req.setAttribute("Response", responseBody);
            } catch (ClientProtocolException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                httpclient.getConnectionManager().shutdown();
            }
            resp.sendRedirect("userDetails.jsp?token=" + token);
        } /*else if(req.getParameter("access_token") != null) {
           Writer w = resp.getWriter();
                    
            w.write("<html><body><center>");
            w.write("<h3>");
            w.write("User Code [" + req.getParameter("access_token") + "] has successfully logged in!");
            w.write("</h3>");
            w.write("</center></body></html>");
                    
            w.flush();
            w.close();   
          } */else {
            Writer w = resp.getWriter();

            w.write("<html><body><center>");
            w.write("<h3>");
            w.write("UNAUTHORIZED Access!");
            w.write("</h3>");
            w.write("</center></body></html>");

            w.flush();
            w.close();
        }

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:by.stub.yaml.stubs.StubRequest.java

public static StubRequest createFromHttpServletRequest(final HttpServletRequest request) throws IOException {
    final StubRequest assertionRequest = StubRequest.newStubRequest(request.getPathInfo(),
            HandlerUtils.extractPostRequestBody(request, "stubs"));
    assertionRequest.addMethod(request.getMethod());

    final Enumeration<String> headerNamesEnumeration = request.getHeaderNames();
    final List<String> headerNames = ObjectUtils.isNotNull(headerNamesEnumeration)
            ? Collections.list(request.getHeaderNames())
            : new LinkedList<String>();
    for (final String headerName : headerNames) {
        final String headerValue = request.getHeader(headerName);
        assertionRequest.getHeaders().put(StringUtils.toLower(headerName), headerValue);
    }//from w w  w. j av a  2  s.c  o m

    assertionRequest.getQuery().putAll(CollectionUtils.constructParamMap(request.getQueryString()));
    ConsoleUtils.logAssertingRequest(assertionRequest);

    return assertionRequest;
}

From source file:org.craftercms.engine.http.impl.HttpProxyImpl.java

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

    return queryString;
}

From source file:com.ebay.pulsar.metric.controller.PulsarReportingController.java

@RequestMapping(value = { "pulsar/metric", "pulsar/counter" }, method = RequestMethod.GET)
@ResponseBody/* w w w.ja v  a  2s . com*/
public String listMetrics(HttpMethod method, HttpServletRequest request, HttpServletResponse response)
        throws URISyntaxException {
    URI uri = new URI("http", null, MetricServer, MetricSeverPort, request.getRequestURI(),
            request.getQueryString(), null);
    ResponseEntity<String> responseEntity = restTemplate.exchange(uri, method, HttpEntity.EMPTY, String.class);
    return responseEntity.getBody();
}

From source file:org.activiti.app.rest.editor.DecisionTablesResource.java

@RequestMapping(method = RequestMethod.GET, produces = "application/json")
public ResultListDataRepresentation getDecisionTables(HttpServletRequest request) {
    // need to parse the filterText parameter ourselves, due to encoding issues with the default parsing.
    String filter = null;/*from  w  w  w. j  a  v  a 2  s .c  o m*/
    List<NameValuePair> params = URLEncodedUtils.parse(request.getQueryString(), Charset.forName("UTF-8"));
    if (params != null) {
        for (NameValuePair nameValuePair : params) {
            if ("filter".equalsIgnoreCase(nameValuePair.getName())) {
                filter = nameValuePair.getValue();
            }
        }
    }
    return decisionTableService.getDecisionTables(filter);
}

From source file:edu.unc.lib.dl.cdr.sword.server.servlets.ContainerServlet.java

@RequestMapping(value = { "/{pid}", "/{pid}/*" }, method = RequestMethod.PUT)
public void replaceMetadataOrMetadataAndContent(HttpServletRequest req, HttpServletResponse resp) {
    try {/*from   w w  w  .  j a  va  2s  .  c o  m*/
        this.api.put(req, resp);
    } catch (Exception e) {
        log.error("Failed to update container " + req.getQueryString(), e);
        resp.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
    }
}

From source file:edu.unc.lib.dl.cdr.sword.server.servlets.ContainerServlet.java

@RequestMapping(value = { "/{pid}", "/{pid}/*" }, method = RequestMethod.POST)
public void addMetadataOrMetadataAndContent(HttpServletRequest req, HttpServletResponse resp) {
    try {/*from   w w w.  jav a2s  .  c o m*/
        this.api.post(req, resp);
    } catch (Exception e) {
        log.error("Failed to update container " + req.getQueryString(), e);
        resp.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
    }
}

From source file:cn.guoyukun.spring.web.interceptor.SetCommonDataInterceptor.java

private String extractCurrentURL(HttpServletRequest request, boolean needQueryString) {
    String url = request.getRequestURI();
    String queryString = request.getQueryString();
    if (!StringUtils.isEmpty(queryString)) {
        queryString = "?" + queryString;
        for (String pattern : excludeParameterPatterns) {
            queryString = queryString.replaceAll(pattern, "");
        }//from w  w  w .j a v a 2 s .  c  o  m
        if (queryString.startsWith("&")) {
            queryString = "?" + queryString.substring(1);
        }
    }
    if (!StringUtils.isEmpty(queryString) && needQueryString) {
        url = url + queryString;
    }
    return getBasePath(request) + url;
}