List of usage examples for javax.servlet.http HttpServletRequest getQueryString
public String getQueryString();
From source file:net.anthonychaves.bookmarks.web.OpenIdController.java
@RequestMapping(value = "/return") public String openIdReturn(HttpServletRequest request, HttpSession session) { // extract the parameters from the authentication response // (which comes in as a HTTP request from the OpenID provider) ParameterList openidResp = new ParameterList(request.getParameterMap()); // retrieve the previously stored discovery information DiscoveryInformation discovered = (DiscoveryInformation) session.getAttribute("discovered"); // extract the receiving URL from the HTTP request StringBuffer receivingURL = request.getRequestURL(); String queryString = request.getQueryString(); if (queryString != null && queryString.length() > 0) { receivingURL.append("?").append(request.getQueryString()); }// w w w . ja v a2 s . c o m // verify the response VerificationResult verification = null; try { verification = manager.verify(receivingURL.toString(), openidResp, discovered); // examine the verification result and extract the verified identifier Identifier verified = verification.getVerifiedId(); if (verified != null) { // success, use the verified identifier to identify the user String[] attributes = inspectOpenIdMessage(verification); User user = userService.findUser(attributes[0]); if (user == null) { user = new User(); user.setEmailAddress(attributes[0]); user.setFirstName(attributes[1]); user.setLastName(attributes[2]); user = userService.createUser(user); } session.setAttribute("user", user); return "redirect:/b/user"; } else { // OpenID authentication failed return "redirect:user_new"; } } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.bluexml.xforms.controller.navigation.NavigationManager.java
protected static Map<String, String> buildParametersMap(HttpServletRequest req) { Map<String, String> map = new HashMap<String, String>(); Map<?, ?> reqp = req.getParameterMap(); for (Map.Entry<?, ?> entry : reqp.entrySet()) { Object value_ = entry.getValue(); if (entry.getKey() instanceof String && value_ instanceof String[]) { String key = (String) entry.getKey(); String value = ((String[]) entry.getValue())[0]; map.put("requests." + key, value); }/*from w w w .j a v a 2 s . c om*/ } // add default parameters map.put("requests.queryString", req.getQueryString().replaceAll("&", "&")); logger.debug("parameterMap :" + map); return map; }
From source file:jp.go.nict.langrid.servicecontainer.handler.jsonrpc.servlet.JsonRpcServlet.java
@Override protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { ByteArrayOutputStream dupIn = null; if (dumpRequests) { String qs = req.getQueryString(); Logger.getAnonymousLogger().info(String.format("method: %s, requestUrl: %s", req.getMethod(), req.getRequestURL().append(qs != null ? "?" + URLDecoder.decode(qs, "UTF-8") : "").toString() ));// ww w . java 2 s.com dupIn = new ByteArrayOutputStream(); req = new AlternateInputHttpServletRequestWrapper(req, new InputStreamServletInputStream(new DuplicatingInputStream(req.getInputStream(), dupIn))); } long s = System.currentTimeMillis(); try { super.service(req, res); } finally { long d = System.currentTimeMillis() - s; if (displayProcessTime) { Logger.getAnonymousLogger().info("processTime: " + d + "ms."); } if (dupIn != null && dupIn.size() > 0) { Logger.getAnonymousLogger() .info(String.format("requestInput: %s", new String(dupIn.toByteArray(), "UTF-8"))); } } }
From source file:com.dreambox.web.logger.LoggingFilter.java
@Override protected void logRequest(HttpServletRequest request) { String uri = request.getRequestURI(); if (isIgnoreUri(uri)) { return;// ww w . jav a 2 s . com } request.setAttribute(REQUEST_START_TIME, System.currentTimeMillis()); HttpSession session = request.getSession(false); String id = ""; if (session != null) { id = session.getId(); } else { id = UUID.randomUUID().toString(); } request.setAttribute(REQUEST_ID_ATTR, id); String method = request.getMethod(); String queryStr = request.getQueryString(); String parameter = getRequestParams(request); String ip = IPUtil.getClientIP(request); Map<String, String> commonPara = new HashMap<String, String>(); commonPara.put("ip", ip); commonPara.put("method", method); commonPara.put("queryStr", queryStr); commonPara.put("parameter", parameter); threadLocalMap.set(commonPara); // log all request l4jlogger.info(String.format(REQUEST_LOG_FORMAT, now(), id, ip, method, uri, queryStr, parameter)); }
From source file:alpine.filters.FqdnForwardFilter.java
/** * Forward requests...../* w w w . j a v a 2s .co m*/ * * @param request The request object. * @param response The response object. * @param chain Refers to the {@code FilterChain} object to pass control to the next {@code Filter}. * @throws IOException a IOException * @throws ServletException a ServletException */ public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { final HttpServletRequest req = (HttpServletRequest) request; final HttpServletResponse res = (HttpServletResponse) response; if (req.getServerName().equals(host)) { chain.doFilter(request, response); return; } res.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); StringBuilder sb = new StringBuilder(); sb.append("http"); if (req.isSecure()) { sb.append("s"); } sb.append("://").append(host); if (StringUtils.isNotBlank(req.getPathInfo())) { sb.append(req.getPathInfo()); } if (StringUtils.isNotBlank(req.getQueryString())) { sb.append("?").append(req.getQueryString()); } res.setHeader("Location", sb.toString()); }
From source file:com.googlecode.psiprobe.controllers.apps.NoSelfContextHandlerController.java
protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request, HttpServletResponse response) throws Exception { try {//from w ww .j a v a2s . c o m if (request.getContextPath().equals(contextName)) { throw new IllegalStateException( getMessageSourceAccessor().getMessage("probe.src.contextAction.cannotActOnSelf")); } executeAction(contextName); } catch (Exception e) { request.setAttribute("errorMessage", e.getMessage()); logger.error(e); return new ModelAndView(new InternalResourceView(getViewName())); } return new ModelAndView(new RedirectView(request.getContextPath() + getViewName() + (isPassQueryString() ? "?" + request.getQueryString() : ""))); }
From source file:com.cloud.bridge.service.controller.s3.S3ObjectAction.java
public void execute(HttpServletRequest request, HttpServletResponse response) throws IOException { String method = request.getMethod(); String queryString = request.getQueryString(); response.addHeader("x-amz-request-id", UUID.randomUUID().toString()); if (method.equalsIgnoreCase("GET")) { if (queryString != null && queryString.length() > 0) { if (queryString.equalsIgnoreCase("acl")) executeGetObjectAcl(request, response); } else//ww w . j a va 2 s.c om executeGetObject(request, response); } else if (method.equalsIgnoreCase("PUT")) { if (queryString != null && queryString.length() > 0) { if (queryString.equalsIgnoreCase("acl")) executePutObjectAcl(request, response); } else executePutObject(request, response); } else if (method.equalsIgnoreCase("DELETE")) { executeDeleteObject(request, response); } else if (method.equalsIgnoreCase("HEAD")) { executeHeadObject(request, response); } else if (method.equalsIgnoreCase("POST")) { executePostObject(request, response); } else throw new IllegalArgumentException("Unsupported method in REST request"); }
From source file:com.fuseim.webapp.ProxyServlet.java
private boolean isInQuery(HttpServletRequest request, String key) { String query = request.getQueryString(); String[] nameValuePairs = query.split("&"); for (String nameValuePair : nameValuePairs) { if (nameValuePair.startsWith(key + "=")) { return true; }//w w w .j av a 2 s. c o m } return false; }
From source file:grails.plugin.cache.web.filter.DefaultWebKeyGenerator.java
public String generate(HttpServletRequest request) { String uri = WebUtils.getForwardURI(request); StringBuilder key = new StringBuilder(); key.append(request.getMethod().toUpperCase()); String format = WebUtils.getFormatFromURI(uri); if (StringUtils.hasLength(format) && !"all".equals(format)) { key.append(":format:").append(format); }// w w w .j a va 2s . co m if (supportAjax) { String requestedWith = request.getHeader(X_REQUESTED_WITH); if (StringUtils.hasLength(requestedWith)) { key.append(':').append(X_REQUESTED_WITH).append(':').append(requestedWith); } } key.append(':').append(uri); if (StringUtils.hasLength(request.getQueryString())) { key.append('?').append(request.getQueryString()); } return key.toString(); }