List of usage examples for javax.servlet.http HttpServletRequest getParameterMap
public Map<String, String[]> getParameterMap();
From source file:org.acoustid.server.util.ParameterMap.java
public static ParameterMap parseRequest(HttpServletRequest request) throws IOException { String contentEncoding = request.getHeader("Content-Encoding"); if (contentEncoding != null) { contentEncoding = contentEncoding.toLowerCase(); }// ww w . java2 s .c om String contentType = request.getContentType(); Map<String, String[]> map; if ("gzip".equals(contentEncoding) && "application/x-www-form-urlencoded".equals(contentType)) { InputStream inputStream = new GZIPInputStream(request.getInputStream()); InputStreamEntity entity = new InputStreamEntity(inputStream, -1); entity.setContentType(contentType); map = new HashMap<String, String[]>(); for (NameValuePair param : URLEncodedUtils.parse(entity)) { String name = param.getName(); String value = param.getValue(); String[] values = map.get(name); if (values == null) { values = new String[] { value }; } else { values = (String[]) ArrayUtils.add(values, value); } map.put(name, values); } } else { map = request.getParameterMap(); } return new ParameterMap(map); }
From source file:org.opentestsystem.authoring.testauth.rest.ScoringRuleController.java
@RequestMapping(value = "/scoringRule/blueprintReferences", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Secured({ "ROLE_Scoring Rule Read" }) @PostAuthorize("hasPermission(returnObject, 'ROLE_Scoring Rule Read')") @ResponseBody/* www.j a va2s . c om*/ public List<BlueprintReference> searchBlueprintReferences(final HttpServletRequest request, final HttpServletResponse response) { return this.scoringRuleService.getBlueprintReferences(request.getParameterMap()); }
From source file:com.surveypanel.form.FormHandler.java
public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException { response.setContentType("text/html;charset=UTF-8"); Map<String, String> values = new HashMap<String, String>(); Map params = request.getParameterMap(); try {//from w ww . jav a2s . c o m for (Object key : params.keySet()) { Object object = params.get(key); if (object instanceof String) { values.put((String) key, (String) object); } else if (object.getClass().isArray()) { StringBuilder sb = new StringBuilder(); String[] value = (String[]) object; for (String content : value) { sb.append(content).append(","); } sb.deleteCharAt(sb.length() - 1); values.put((String) key, sb.toString()); } } } catch (Exception e) { e.printStackTrace(); } if (params.containsKey("quit")) { quit = true; } Form form = null; if (!values.containsKey("formId")) { form = formFactory.create(surveyId, devMode); } else { form = formFactory.load(values.get("formId"), surveyId, devMode); } form.setValues(values); form.setDevMode(devMode); Result execute; try { execute = (Result) jsManager.execute(form, "flow.execute(survey); save();"); System.out.println(execute.getLogs()); if (execute.hasError()) { response.getWriter().write(execute.getError()); } else { response.getWriter().write(execute.getDisplay()); } } catch (Exception e) { e.printStackTrace(); response.getWriter().write(e.getMessage()); } response.flushBuffer(); }
From source file:org.esupportail.dining.web.controllers.EditController.java
@RequestMapping(params = { "action=nutritionPreferences" }) public String setUserNutritionPreferences(HttpServletRequest request) throws Exception { String userLogin = this.authenticator.getUser().getLogin(); Map parameters = request.getParameterMap(); int[] code = { 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15 }; for (int i = 0; i < code.length; i++) { if (parameters.get("code-" + code[i]) != null) { try { this.dc.executeUpdate("INSERT INTO nutritionPreferences (USERNAME, NUTRITIONCODE) VALUES ('" + StringEscapeUtils.escapeSql(userLogin) + "', '" + code[i] + "');"); } catch (SQLException e) { /**/ }//from w w w .j av a 2 s. co m } else { /* * uncheck boxes need to be deleted from the db if it goes into * the catch it mean the row didn't exist and it doesn't need * specific treatment */ try { this.dc.executeUpdate("DELETE FROM nutritionPreferences WHERE USERNAME='" + StringEscapeUtils.escapeSql(userLogin) + "' AND NUTRITIONCODE='" + code[i] + "';"); } catch (SQLException e) { /**/ } } } return "redirect:/settings?nutritSubmit=true"; }
From source file:com.shenit.commons.utils.HttpUtils.java
/** * ??Hash. Map<String,String[]>/*from w ww. j a v a2s. com*/ * ?Map<String,String>??,? * * @param req * @return */ public static Map<String, String> getParamMap(HttpServletRequest req) { Map<String, String[]> params = req.getParameterMap(); Map<String, String> result = new HashMap<String, String>(); Set<String> keys = params.keySet(); for (String key : keys) result.put(key, getParam(params, key)); return result; }
From source file:org.projectbuendia.openmrs.web.controller.ProfileManager.java
/** This method sends data to jsp in a more consistent way. */ private ModelMap queryParamsToModelAttr(HttpServletRequest request, ModelMap model) { Map params = request.getParameterMap(); Iterator paramIterator = params.entrySet().iterator(); while (paramIterator.hasNext()) { Entry param = (Entry) paramIterator.next(); String key = (String) param.getKey(); String[] value = (String[]) param.getValue(); model.addAttribute(key, value[0]); }/*from w w w . j a v a 2 s. c o m*/ return model; }
From source file:com.doitnext.http.router.DefaultInvoker.java
private Map<String, String[]> parseQueryArgs(HttpServletRequest req) { Map<String, String[]> result = new HashMap<String, String[]>(); Map<String, String[]> parameterMap = req.getParameterMap(); String queryString = req.getQueryString(); for (Entry<String, String[]> entry : parameterMap.entrySet()) { if (queryString.contains(String.format("%s=", entry.getKey()))) { result.put(entry.getKey(), entry.getValue()); }/* ww w . j a v a 2 s . c om*/ } return result; }
From source file:com.sammyun.plugin.alipayDirect.AlipayDirectPlugin.java
/** * ???//from www. ja v a 2 s . c o m * * @param parameterMap ? * @return ?? */ private String generateMobileSign(HttpServletRequest request) { // ??POST???? Map<String, Object> params = new HashMap<String, Object>(); Map requestParams = request.getParameterMap(); for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) { String name = (String) iter.next(); String[] values = (String[]) requestParams.get(name); String valueStr = ""; for (int i = 0; i < values.length; i++) { valueStr = (i == values.length - 1) ? valueStr + values[i] : valueStr + values[i] + ","; } // ???mysignsign??? params.put(name, valueStr); } // ?signsign_type? Map<String, Object> sParaNew = PaymentPlugin.paraFilter(params); // ??? String preSignStr = PaymentPlugin.createLinkString(sParaNew); // ??? return preSignStr; }
From source file:org.schedoscope.metascope.service.MetascopeURLService.java
public String getFilterURL(HttpServletRequest request, String key, String value) { value = cleanseValue(value);/*from w w w. jav a 2 s. c o m*/ String queryParams = ""; boolean keyAlreadyExists = false; for (Entry<String, String[]> e : request.getParameterMap().entrySet()) { if (e.getKey().equals(URLUtil.PAGINATION_PAGE_PARAM)) { queryParams = addKey(queryParams, e.getKey(), "1"); } else if (key.equals(e.getKey())) { keyAlreadyExists = true; String paramValue = cleanseValue(e.getValue()[0]); if (!value.equals(paramValue)) { boolean alreadyContainsValue = false; for (String v : paramValue.split(ENCODED_COMMA)) { if (value.equals(v)) { queryParams = removeValueFromKey(queryParams, e.getKey(), paramValue, value); alreadyContainsValue = true; } } if (!alreadyContainsValue) { queryParams = addKey(queryParams, e.getKey(), paramValue + COMMA + value); } } } else { queryParams = addKey(queryParams, e.getKey(), cleanseValue(e.getValue()[0])); } } if (!keyAlreadyExists) { queryParams = addKey(queryParams, key, value); } return request.getRequestURL() + URL_PARAMS_DIVIDER + queryParams; }
From source file:com.formkiq.core.service.entry.WorkflowEntryFlowEventProcessor.java
/** * Add Signature Metadata.// www . j a v a2 s . c o m * * @param flow {@link WebFlow} * @param request {@link HttpServletRequest} */ public void eventIdsignaturemetadata(final WebFlow flow, final HttpServletRequest request) { FormJSON form = flow.getCurrentState().getData(); Map<String, String[]> params = new HashMap<>(request.getParameterMap()); params.put("inserteddate", new String[] { this.jsonService.dateToString(this.dateservice.now()) }); params.put("ipaddress", new String[] { request.getRemoteAddr() }); params.put("xforwardedfor", new String[] { StringUtils.defaultString(request.getHeader("X-FORWARDED-FOR"), "") }); for (Map.Entry<String, String[]> e : params.entrySet()) { Optional<FormJSONField> field = findValueByKey(form, e.getKey()); if (field.isPresent()) { if (isEmpty(field.get().getValue())) { field.get().setValue(Arrays.first(e.getValue())); } } } }