List of usage examples for javax.servlet.http HttpServletRequest getQueryString
public String getQueryString();
From source file:com.yahoo.glimmer.web.QueryController.java
@ExceptionHandler(Exception.class) public Map<String, ?> handleException(Exception ex, HttpServletRequest request, HttpServletResponse response) { if (!(ex instanceof HttpMessageConversionException)) { LOGGER.error("Exception when processing:" + request.getQueryString(), ex); }/*from www . java 2s . c om*/ response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return Collections.singletonMap(OBJECT_KEY, ex.getMessage()); }
From source file:com.indoqa.httpproxy.HttpClientProxy.java
private String createProxyUrl(HttpServletRequest request) { StringBuilder builder = new StringBuilder(this.targetBaseUri); builder.append(this.createProxyPath(request)); String queryString = request.getQueryString(); if (queryString != null) { builder.append("?"); builder.append(queryString);/* www . j a v a 2 s . co m*/ } return builder.toString(); }
From source file:am.ik.categolj2.core.web.accesslog.AccessLogMethodArgumentResolver.java
@Override public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class); String xTrack = StringUtils.substring((String) request.getAttribute("X-Track"), 0, 32); String method = request.getMethod(); String uri = StringUtils.substring(request.getRequestURI(), 0, 128); String query = StringUtils.substring(request.getQueryString(), 0, 128); String remoteAddress = RemoteAddresses.getRemoteAddress(request); String userAgent = UserAgents.getUserAgent(request); DateTime accessDate = dateFactory.newDateTime(); return new AccessLog(null, method, uri, query, remoteAddress, userAgent, xTrack, accessDate); }
From source file:net.groupbuy.plugin.yeepay.YeepayPlugin.java
@Override public boolean verifyNotify(String sn, NotifyMethod notifyMethod, HttpServletRequest request) { PluginConfig pluginConfig = getPluginConfig(); Payment payment = getPayment(sn);//www . jav a 2 s . co m Map<String, String[]> parameterValuesMap = WebUtils.getParameterMap(request.getQueryString(), "GBK"); Map<String, Object> parameterMap = new LinkedHashMap<String, Object>(); parameterMap.put("p1_MerId", parameterValuesMap.get("p1_MerId")); parameterMap.put("r0_Cmd", parameterValuesMap.get("r0_Cmd")); parameterMap.put("r1_Code", parameterValuesMap.get("r1_Code")); parameterMap.put("r2_TrxId", parameterValuesMap.get("r2_TrxId")); parameterMap.put("r3_Amt", parameterValuesMap.get("r3_Amt")); parameterMap.put("r4_Cur", parameterValuesMap.get("r4_Cur")); parameterMap.put("r5_Pid", parameterValuesMap.get("r5_Pid")); parameterMap.put("r6_Order", parameterValuesMap.get("r6_Order")); parameterMap.put("r7_Uid", parameterValuesMap.get("r7_Uid")); parameterMap.put("r8_MP", parameterValuesMap.get("r8_MP")); parameterMap.put("r9_BType", parameterValuesMap.get("r9_BType")); if (generateSign(parameterMap).equals(parameterValuesMap.get("hmac")[0]) && pluginConfig.getAttribute("partner").equals(parameterValuesMap.get("p1_MerId")[0]) && sn.equals(parameterValuesMap.get("r6_Order")[0]) && "1".equals(parameterValuesMap.get("r1_Code")[0]) && payment.getAmount().compareTo(new BigDecimal(parameterValuesMap.get("r3_Amt")[0])) == 0) { return true; } return false; }
From source file:org.esgf.solr.proxy.SolrProxyController.java
private String relay(HttpServletRequest request, HttpServletResponse response) { System.out.println("--TIME MEASUREMENT FOR LOADING RESULTS--"); long beginTime = System.nanoTime(); String queryString = request.getQueryString(); LOG.debug("queryString=" + queryString); String requestUri = request.getRequestURI(); LOG.debug("requestUri=" + requestUri); String urlString = solrURL + "select?" + queryString + "&wt=json"; String responseBody = null;// w w w . jav a2 s .c o m // create an http client HttpClient client = new HttpClient(); // create a method instance GetMethod method = new GetMethod(urlString); // custom retry method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); try { // execute the method int statusCode = client.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { LOG.error("Method failed: " + method.getStatusLine()); } // read the response responseBody = method.getResponseBodyAsString(); } catch (HTTPException e) { LOG.error("Fatal protocol violation"); e.printStackTrace(); } catch (IOException e) { LOG.error("Fatal transport error"); e.printStackTrace(); } finally { method.releaseConnection(); } LOG.debug("Solr URL = " + urlString); //LOG.debug("responseBody = " + responseBody); long endTime = System.nanoTime(); System.out.println("\tTotal Time: " + ((int) (endTime - beginTime)) + "ns"); System.out.println("-----------------------------------------"); return responseBody; }
From source file:eu.simpaticoproject.ife.controller.ProxyController.java
@RequestMapping(value = "/api/proxy/wikipedia", method = RequestMethod.GET) public @ResponseBody HttpEntity<byte[]> wikipedia(@RequestParam String content, HttpServletRequest request) throws Exception { String urlToCall = wikipediaUrl; if (Utils.isNotEmpty(request.getQueryString())) { urlToCall = urlToCall + "?action=parse&contentmodel=wikitext&prop=text&format=json&page=" + URLEncoder.encode(content, "UTF-8"); }/* www. j a v a2 s . c o m*/ if (logger.isInfoEnabled()) { logger.info("wikipedia:" + urlToCall); } GetMethod responseConnection = HTTPUtils.getConnection(urlToCall, null, null, null, null, request); HttpHeaders headers = new HttpHeaders(); Header[] responseHeaders = responseConnection.getResponseHeaders(); for (Header header : responseHeaders) { headers.add(header.getName(), header.getValue()); } InputStream is = responseConnection.getResponseBodyAsStream(); byte[] byteStream = IOUtils.toByteArray(is); return new HttpEntity<byte[]>(byteStream, headers); }
From source file:com.epam.trade.storefront.filters.StorefrontFilter.java
@Override public void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws IOException, ServletException { final HttpSession session = request.getSession(); final String queryString = request.getQueryString(); if (isSessionNotInitialized(session, queryString)) { initDefaults(request);// w ww . ja v a 2s. com markSessionInitialized(session); } // For secure requests ensure that the JSESSIONID cookie is visible to insecure requests if (isRequestSecure(request)) { fixSecureHttpJSessionIdCookie(request, response); } if (isGetMethod(request) || isPostMethod(request)) { if (StringUtils.isBlank(request.getHeader(AJAX_REQUEST_HEADER_NAME))) { final String requestURL = request.getRequestURL().toString(); session.setAttribute(ORIGINAL_REFERER, StringUtils.isNotBlank(queryString) ? requestURL + "?" + queryString : requestURL); } getBrowseHistory().addBrowseHistoryEntry(new BrowseHistoryEntry(request.getRequestURI(), null)); } filterChain.doFilter(request, response); }
From source file:net.sf.j2ep.ProxyFilter.java
/** * Will build a URI but including the Query String. That means that it really * isn't a URI, but quite near.// w ww . j a va 2 s. co m * * @param httpRequest Request to get the URI and query string from * @return The URI for this request including the query string */ private String getURI(HttpServletRequest httpRequest) { String contextPath = httpRequest.getContextPath(); String uri = httpRequest.getRequestURI().substring(contextPath.length()); if (httpRequest.getQueryString() != null) { uri += "?" + httpRequest.getQueryString(); } return uri; }
From source file:com.ebay.pulsar.metric.servlet.MetricRestServlet.java
private void getMetrics(final HttpServletRequest request, final String pathInfo, final HttpServletResponse response) throws Exception { String queryString = request.getQueryString(); QueryParam queryParam = getCassandraQueryParam(queryString); ListenableFuture<List<RawNumericMetric>> future = metricService.findData(queryParam); try {//from ww w .ja v a 2 s . c om List<RawNumericMetric> metrics = future.get(5000, TimeUnit.MILLISECONDS); String result = metricResultWriter.writeValueAsString(metrics); response.getWriter().print(result); response.setContentLength(result.length()); response.setStatus(HttpServletResponse.SC_OK); } catch (TimeoutException e) { response.getWriter().print(QUERY_CASSANDRA_TIMEOUT); response.setContentLength(QUERY_CASSANDRA_TIMEOUT.length()); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } catch (ExecutionException e) { response.getWriter().print(QUERY_CASSANDRA_ERROR); response.setContentLength(QUERY_CASSANDRA_ERROR.length()); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
From source file:com.ebay.pulsar.metric.servlet.MetricRestServlet.java
private void getCounters(final HttpServletRequest request, final String pathInfo, final HttpServletResponse response) throws Exception { String queryString = request.getQueryString(); QueryParam queryParam = getCassandraQueryParam(queryString); ListenableFuture<List<Counter>> future = metricService.findCounters( (String) queryParam.getParameters().get(QueryParam.METRIC_NAME), (String) queryParam.getParameters().get(QueryParam.GROUP_ID)); try {//from w w w .j a v a 2 s . c o m List<Counter> counters = future.get(5000, TimeUnit.MILLISECONDS); String result = counterResultWriter.writeValueAsString(counters); response.getWriter().print(result); response.setContentLength(result.length()); response.setStatus(HttpServletResponse.SC_OK); } catch (TimeoutException e) { response.getWriter().print(QUERY_CASSANDRA_TIMEOUT); response.setContentLength(QUERY_CASSANDRA_TIMEOUT.length()); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } catch (ExecutionException e) { response.getWriter().print(QUERY_CASSANDRA_ERROR); response.setContentLength(QUERY_CASSANDRA_ERROR.length()); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }