List of usage examples for javax.servlet.http HttpServletRequest getParameterNames
public Enumeration<String> getParameterNames();
Enumeration
of String
objects containing the names of the parameters contained in this request. From source file:azkaban.server.HttpRequestUtils.java
public static Map<String, String> getParamGroup(HttpServletRequest request, String groupName) throws ServletException { @SuppressWarnings("unchecked") Enumeration<Object> enumerate = (Enumeration<Object>) request.getParameterNames(); String matchString = groupName + "["; HashMap<String, String> groupParam = new HashMap<String, String>(); while (enumerate.hasMoreElements()) { String str = (String) enumerate.nextElement(); if (str.startsWith(matchString)) { groupParam.put(str.substring(matchString.length(), str.length() - 1), request.getParameter(str)); }// w w w. j a va2 s . c o m } return groupParam; }
From source file:com.mobileman.projecth.web.util.UserUtils.java
/** * @param request//from w w w .ja va 2s .c o m * @param doctor */ public static void saveDiseases(HttpServletRequest request, User doctor, UserService userService, DiseaseService diseaseService) { List<Long> diseaseIds = new ArrayList<Long>(); for (@SuppressWarnings("unchecked") Enumeration<String> e = request.getParameterNames(); e.hasMoreElements();) { String nameStr = e.nextElement(); if (nameStr.startsWith("disease")) { String value = request.getParameter(nameStr); Long diseaseId = NumUtils.convert2long(value); diseaseIds.add(diseaseId); } } List<Disease> addDiseases = new ArrayList<Disease>(); List<Disease> removeDiseases = new ArrayList<Disease>(); //add new diseases for (Long diseaseId : diseaseIds) { if (!UserUtils.containsDisease(diseaseId, doctor.getDiseases())) { addDiseases.add(diseaseService.findById(diseaseId)); } } //remove old diseases for (Disease disease : doctor.getDiseases()) { if (!diseaseIds.contains(disease.getId())) { removeDiseases.add(disease); } } if (addDiseases.size() > 0) { userService.addDiseasesToUser(doctor.getId(), addDiseases); } if (removeDiseases.size() > 0) { userService.removeDiseasesFromUser(doctor.getId(), removeDiseases); } }
From source file:com.jslsolucoes.tagria.lib.util.TagUtil.java
public static String queryString(HttpServletRequest request, List<String> excludesParams) throws UnsupportedEncodingException { List<String> queryString = new ArrayList<>(); Enumeration<String> en = request.getParameterNames(); while (en.hasMoreElements()) { String paramName = en.nextElement(); if (!excludesParams.contains(paramName)) queryString.add(paramName + "=" + URLEncoder.encode(request.getParameter(paramName), "UTF-8")); }/* w ww . j a v a 2 s.co m*/ return StringUtils.join(queryString, '&'); }
From source file:net.mindengine.oculus.frontend.service.customization.CustomizationUtils.java
public static Map<Long, CustomizationCriteria> collectCustomizationSearchCriteriaParameters( HttpServletRequest request) { Map<Long, CustomizationCriteria> map = new HashMap<Long, CustomizationCriteria>(); Enumeration<?> params = request.getParameterNames(); while (params.hasMoreElements()) { String param = (String) params.nextElement(); if (param.startsWith("customization_")) { String strCustomization = param.substring(14); int idPV = strCustomization.indexOf("_pv_"); int idFP = strCustomization.indexOf("_fetch_type"); boolean checklist = false; Long customizationId = null; Integer fetchConditionType = null; String value = null;//from w w w .j a v a 2 s .c o m if (idPV > 0) { // The parameter is part of checklist checklist = true; customizationId = Long.parseLong(strCustomization.substring(0, idPV)); if ("on".equals(request.getParameter(param))) { value = strCustomization.substring(idPV + 4); } } else if (idFP > 0) { // The parameter is a part of checklist fetch type // specification customizationId = Long.parseLong(strCustomization.substring(0, idFP)); checklist = true; String strFP = request.getParameter(param); if ("1".equals(strFP)) { fetchConditionType = CustomizationCriteria.FETCH_TYPE_STRICT; } else fetchConditionType = CustomizationCriteria.FETCH_TYPE_AT_LEAST_ONE; } else { customizationId = Long.parseLong(strCustomization); value = StringEscapeUtils.escapeSql(request.getParameter(param)); } if (!map.containsKey(customizationId)) { CustomizationCriteria criteria = new CustomizationCriteria(); criteria.setValues(new LinkedList<String>()); map.put(customizationId, criteria); } CustomizationCriteria criteria = map.get(customizationId); if (value != null) { criteria.getValues().add(value); } if (fetchConditionType != null) { criteria.setFetchConditionType(fetchConditionType); } criteria.setChecklist(checklist); } } return map; }
From source file:doc.action.SelectedDocsUtils.java
public static Collection saveSelectedDocsIDs(HttpServletRequest request) { //System.out.println("start"); Collection documents = (Collection) request.getSession().getAttribute(Constant.SELECTED_PRESIDENTS); //System.out.println(documents); if (documents == null) { documents = new ArrayList(); request.getSession().setAttribute(Constant.SELECTED_PRESIDENTS, documents); }/*from w w w . ja v a 2s . c o m*/ Enumeration parameterNames = request.getParameterNames(); while (parameterNames.hasMoreElements()) { String parameterName = (String) parameterNames.nextElement(); if (parameterName.startsWith("chkbx_")) { String docId = StringUtils.substringAfter(parameterName, "chkbx_"); String parameterValue = request.getParameter(parameterName); if (parameterValue.equals(Constant.SELECTED)) { if (!documents.contains(docId)) { documents.add(docId); } } else { documents.remove(docId); } } } return documents; }
From source file:com.netspective.sparx.util.HttpUtils.java
/** * Given a list of HTTP parameter names, assign their current values using appropriate accessor methods of the * instance object (using Java reflection). * * @param req The HTTP servlet request * @param instance The object who's mutator methods should be matched * @param paramNames The names of the parameters that should be assigned to the mutators of the instance object. * This may be '*' (for all parameters) or a comma-separated list of names. The parameter names * may optionally be followed by an '=' to indicate a default value for the parameter. Parameter * names may optionally be terminated with an '!' to indicate that they are required (an exception * is thrown if the parameter is unavailable. For example, "a,b!,c" would mean that parameter * 'a', 'b' and 'c' should be assigned using setA(), setB() and setC() if available but an * exception should be thrown if 'b' is not available as a request parameter. *//*from w w w . ja v a 2s. c o m*/ public static void assignParamsToInstance(HttpServletRequest req, Object instance, String paramNames) throws IllegalAccessException, InvocationTargetException, DataModelException { XmlDataModelSchema schema = XmlDataModelSchema.getSchema(instance.getClass()); if (paramNames.equals("*")) { for (Enumeration e = req.getParameterNames(); e.hasMoreElements();) { String paramName = (String) e.nextElement(); assignParamToInstance(req, schema, instance, paramName, null); } } else { String[] retainParams = TextUtils.getInstance().split(paramNames, ",", true); for (int i = 0; i < retainParams.length; i++) { String paramName = retainParams[i]; int defaultValuePos = paramName.indexOf('='); if (defaultValuePos > 0) assignParamToInstance(req, schema, instance, paramName.substring(0, defaultValuePos), paramName.substring(defaultValuePos + 1)); else assignParamToInstance(req, schema, instance, paramName, null); } } }
From source file:com.jaspersoft.jasperserver.rest.RESTUtils.java
/** * Look for parameters provided by the client. * * @param req HttpServletRequest/* w ww . j a va2s. c o m*/ * @return Map<String,Object> */ public static Map<String, Object> extractParameters(HttpServletRequest req) { Map<String, Object> parameters = new HashMap<String, Object>(); Enumeration penum = req.getParameterNames(); while (penum.hasMoreElements()) { String pname = (String) penum.nextElement(); if (pname.startsWith("P_")) { parameters.put(pname.substring(2), req.getParameter(pname)); } else if (pname.startsWith("PL_")) { parameters.put(pname.substring(3), Arrays.asList(req.getParameterValues(pname))); } } return parameters; }
From source file:edu.ucsb.nceas.metacat.util.RequestUtil.java
/** * Get a cookie from a request by the cookie name * //from w w w. ja v a2 s . c o m * @param request * the request from which to get the cookie * @param cookieName * the name of the cookie to look for */ @SuppressWarnings("unchecked") public static Hashtable<String, String[]> getParameters(HttpServletRequest request) { Hashtable<String, String[]> params = new Hashtable<String, String[]>(); Enumeration<String> paramlist = (Enumeration<String>) request.getParameterNames(); while (paramlist.hasMoreElements()) { String name = (String) paramlist.nextElement(); String[] value = request.getParameterValues(name); params.put(name, value); } return params; }
From source file:com.concursive.connect.web.portal.ProjectPortalURLParserImpl.java
public static void addAllParameters(HttpServletRequest request, PortalURL portalURL) { Enumeration params = request.getParameterNames(); while (params.hasMoreElements()) { String parameter = (String) params.nextElement(); String value = request.getParameter(parameter); if (StringUtils.hasText(value)) { if (!parameter.startsWith(PREFIX + RENDER_PARAM) && !parameter.equals("portletWindowState1") && !parameter.startsWith("portlet-") && !(parameter.equals("command") && "ProjectCenter".equals(value))) { if (StringUtils.hasText(value)) { LOG.debug("Made a parameter available to the portlet: " + parameter); portalURL.addParameter(new PortalURLParameter(portalURL.getRenderPath(), parameter, value)); }//from ww w . j av a 2 s .c om } else { if ("portlet-command".equals(parameter)) { LOG.debug("Made a parameter available to the portlet: " + parameter); portalURL.addParameter(new PortalURLParameter(portalURL.getRenderPath(), parameter, value)); } } } } }
From source file:com.easyjf.web.core.FrameworkEngine.java
/** * reuqest?map?/*from w w w . j a va 2 s . com*/ * * @param request * @return Map */ public static Map request2map(HttpServletRequest request) { Map map = new HashMap(); java.util.Enumeration s = request.getParameterNames(); // System.out.println("?"+request.getParameterMap().size()); while (s.hasMoreElements()) { String name = (String) s.nextElement(); // eliminateScript((String)request.getParameter(name)));//? String[] vs = request.getParameterValues(name); if (vs == null || vs.length < 1) map.put(name, null); else map.put(name, vs.length > 1 ? vs : vs[0]); } return map; }