List of usage examples for javax.servlet.http HttpServletRequest getParameterMap
public Map<String, String[]> getParameterMap();
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 ww w . jav a2 s . com*/ } // add default parameters map.put("requests.queryString", req.getQueryString().replaceAll("&", "&")); logger.debug("parameterMap :" + map); return map; }
From source file:com.formkiq.core.api.FeedsController.java
/** * Gets a Feed and transfers XML to JSON. * @param request {@link HttpServletRequest} * @param response {@link HttpServletResponse} * @throws IOException IOException// ww w. j a va 2 s. c o m * @throws InvalidFeedUrlException InvalidFeedUrlException */ @RequestMapping(value = API_FEEDS_GET) public void get(final HttpServletRequest request, final HttpServletResponse response) throws IOException, InvalidFeedUrlException { getApiVersion(request); Map<String, String[]> map = request.getParameterMap(); String url = getParameter(map, "url", true).trim(); ResponseEntity<String> entity = this.feedService.get(url); String body = entity.getBody(); if (this.feedService.isXMLContentType(entity.getHeaders())) { body = this.feedService.toJSONFromXML(body); } else if (!this.feedService.isJSONContentType(entity.getHeaders())) { List<String> contentTypes = entity.getHeaders().get("content-type"); String ct = !contentTypes.isEmpty() ? contentTypes.get(0) : "unknown content type"; throw new InvalidFeedUrlException("Invalid content-type " + ct + " for " + url); } response.setContentType("application/json"); response.setContentLengthLong(body.length()); IOUtils.write(body, response.getOutputStream(), Strings.CHARSET_UTF8); }
From source file:com.sun.j2ee.blueprints.waf.controller.impl.ClientStateFlowHandler.java
public String processFlow(HttpServletRequest request) throws FlowHandlerException { String forwardScreen = request.getParameter("referring_screen"); // de-serialize the request attributes. Map params = (Map) request.getParameterMap(); HashMap newParams = new HashMap(); String cacheId = request.getParameter("cacheId"); if (!params.isEmpty()) { Iterator it = params.keySet().iterator(); // put the request attributes stored in the session in the request while (it.hasNext()) { String key = (String) it.next(); if (key.startsWith(cacheId + "_attribute_")) { String[] values = (String[]) params.get(key); String valueString = values[0]; byte[] bytes = Base64.decode(valueString.getBytes()); try { ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes)); Object requestObject = requestObject = ois.readObject(); ois.close();/*www. j a v a 2 s . c o m*/ // put the de-serialized object back into the request String requestObjectKey = key.substring((cacheId + "_attribute_").length(), key.length()); request.setAttribute(requestObjectKey, requestObject); } catch (java.io.OptionalDataException ode) { logger.error("ClientCacheLinkFlowHandler caught: ", ode); } catch (java.lang.ClassNotFoundException cnfe) { logger.error("ClientCacheLinkFlowHandler caught: ", cnfe); } catch (java.io.IOException iox) { logger.error("ClientCacheLinkFlowHandler caught: ", iox); } } } } return forwardScreen; }
From source file:CPD4414Assign3.ProductServlet.java
protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException { Set<String> keySet = request.getParameterMap().keySet(); try (PrintWriter out = response.getWriter()) { Connection conn = getConnection(); if (keySet.contains("productID")) { PreparedStatement pstmt = conn.prepareStatement( "DELETE FROM `product` WHERE `productID`=" + request.getParameter("productID")); try { pstmt.executeUpdate();/*ww w.j a va 2 s.c o m*/ } catch (SQLException ex) { Logger.getLogger(ProductServlet.class.getName()).log(Level.SEVERE, null, ex); out.println("Error deleting entry."); response.setStatus(500); } } else { out.println("Error: Not enough data to delete"); response.setStatus(500); } } catch (SQLException ex) { Logger.getLogger(ProductServlet.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.appverse.web.framework.backend.frontfacade.mvc.swagger.controller.SwaggerOAuth2Controller.java
@RequestMapping(value = "/swaggeroauth2login", method = RequestMethod.GET) public String showSwaggerOAuth2LoginForm(Model model, HttpServletRequest req) throws MalformedURLException { String contextPath = req.getContextPath(); model.addAttribute("response_type", "token"); Map<String, String[]> map = req.getParameterMap(); model.addAllAttributes(convertParameters(map)); model.addAttribute("redirect_uri", req.getParameter("redirect_uri")); if (oauthAuthServerBaseUrl != null && !oauthAuthServerBaseUrl.isEmpty()) { // Is an external OAuth2 provider, not in the same webapplication as the resource server model.addAttribute("swaggerLoginFormAction", oauthAuthServerBaseUrl + oauth2LoginEndpoint); } else {/* ww w. j a va2 s. co m*/ // The OAuth2 provider and the resource server reside in the same web application model.addAttribute("swaggerLoginFormAction", convertToRelativePath(contextPath, oauth2LoginEndpoint)); } model.addAttribute("swaggerClientId", swaggerClientId); return "oauth2loginform"; }
From source file:cn.sel.wetty.interceptor.AccessLogger.java
private void i(HttpServletRequest request) { String msg = String.format("%s -> %s\t[%s]\tHeaders:%s\tParameters:%s", request.getRemoteAddr(), request.getRequestURI(), request.getMethod(), getHeaders(request), request.getParameterMap()); LOGGER.info(msg);// ww w . ja v a2s . c o m }
From source file:controller.NavigatorServlet.java
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println(request.getParameterMap().toString()); String page = request.getParameter("page"); String type = request.getParameter("type"); System.out.println(page);/*from w ww . j a v a2s . c o m*/ System.out.println(type); CloseableHttpClient httpClient = HttpClients.createDefault(); String address = "http://127.0.0.1:8080"; HttpPost httpPost; List<NameValuePair> nvps = new ArrayList<NameValuePair>(); if (type.equalsIgnoreCase("GetPage")) { switch (page) { case "LogIn": address += "/CloudChatUserManagerClient/loginPage.html"; break; case "LogOut": address += "/CloudChatUserManagerClient/logoutConfirm.html"; break; case "LogInSuccess": address += "/CloudChatUserManagerClient/loginSuccessPage.html"; break; case "Register": System.out.println("Got here"); address += "/CloudChatUserManagerClient/registrationPage.html"; break; case "Edit": address += "/CloudChatServer/edit.jsp"; break; case "Delete": address += "/CloudChatServer/delete.jsp"; break; case "ChatHome": address += "/CloudChatServer/chat.jsp"; break; default: address = ""; break; } } else if (type.equalsIgnoreCase("UserManager")) { address += "/CloudChatUserManagerClient/CloudChatUserManagerServlet"; nvps.add(new BasicNameValuePair("action", request.getParameter("action"))); nvps.add(new BasicNameValuePair("userID", request.getParameter("userID"))); nvps.add(new BasicNameValuePair("password", request.getParameter("password"))); } else if (type.equalsIgnoreCase("Server")) { System.out.println("Got here"); address += "/CloudChatServer/chat"; nvps.add(new BasicNameValuePair("userID", request.getParameter("userID"))); nvps.add(new BasicNameValuePair("action", request.getParameter("action"))); nvps.add(new BasicNameValuePair("messageID", request.getParameter("messageID"))); nvps.add(new BasicNameValuePair("message", request.getParameter("message"))); nvps.add(new BasicNameValuePair("category", request.getParameter("category"))); } httpPost = new HttpPost(address); httpPost.setEntity(new UrlEncodedFormEntity(nvps)); CloseableHttpResponse httpResponse = httpClient.execute(httpPost); try { System.out.println(httpResponse.getStatusLine()); HttpEntity entity = httpResponse.getEntity(); BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent())); String line; String res = ""; while ((line = reader.readLine()) != null) { res += line; } EntityUtils.consume(entity); response.getWriter().write(res); } finally { httpResponse.close(); } }
From source file:org.duracloud.duradmin.spaces.controller.SpaceController.java
private void populateSpaceCount(Space space, HttpServletRequest request) throws Exception { //flush space count cache if (request.getParameterMap().containsKey("recount")) { expireItemCount(request, space); }/* w w w .ja v a 2 s . c o m*/ String countStr = space.getProperties().getCount(); if (countStr.endsWith("+")) { setItemCount(space, request); } else { space.setItemCount(Long.valueOf(space.getProperties().getCount())); } }
From source file:io.lavagna.web.security.login.PersonaLogin.java
@Override public boolean doAction(HttpServletRequest req, HttpServletResponse resp) throws IOException { if (!("POST".equalsIgnoreCase(req.getMethod()) && req.getParameterMap().containsKey("assertion"))) { resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); return true; }/* w w w. ja va2 s.c om*/ String audience = configurationRepository.getValue(Key.PERSONA_AUDIENCE); MultiValueMap<String, String> toPost = new LinkedMultiValueMap<>(); toPost.add("assertion", req.getParameter("assertion")); toPost.add("audience", audience); VerifierResponse verifier = restTemplate.postForObject("https://verifier.login.persona.org/verify", toPost, VerifierResponse.class); if ("okay".equals(verifier.status) && audience.equals(verifier.audience) && userRepository.userExistsAndEnabled(USER_PROVIDER, verifier.email)) { String url = Redirector.cleanupRequestedUrl(req.getParameter("reqUrl")); UserSession.setUser(userRepository.findUserByName(USER_PROVIDER, verifier.email), req, resp, userRepository); resp.setStatus(HttpServletResponse.SC_OK); resp.setContentType("application/json"); JsonObject jsonObject = new JsonObject(); jsonObject.add("redirectTo", new JsonPrimitive(url)); resp.getWriter().write(jsonObject.toString()); } else { resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); } return true; }
From source file:productClass.java
@Override protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException { Set<String> keySet = request.getParameterMap().keySet(); try (PrintWriter out = response.getWriter()) { Connection conn = getConnection(); if (keySet.contains("productID")) { PreparedStatement pstmt = conn.prepareStatement( "DELETE FROM `product` WHERE `productID`=" + request.getParameter("productID")); try { pstmt.executeUpdate();/*w w w . j a v a 2 s.com*/ } catch (SQLException ex) { Logger.getLogger(productClass.class.getName()).log(Level.SEVERE, null, ex); out.println("Error in deleting the product."); } } else { out.println("Error: in data to delete"); } } catch (SQLException ex) { Logger.getLogger(productClass.class.getName()).log(Level.SEVERE, null, ex); } }