List of usage examples for javax.servlet.http HttpServletRequest getParameterValues
public String[] getParameterValues(String name);
String
objects containing all of the values the given request parameter has, or null
if the parameter does not exist. From source file:fr.paris.lutece.util.http.SecurityUtil.java
/** * Write request parameters infos into the dump stringbuffer * @param sb The dump stringbuffer// ww w .ja v a 2s .co m * @param request The HTTP request */ private static void dumpParameters(StringBuffer sb, HttpServletRequest request) { String key; String[] values; Enumeration<String> e = request.getParameterNames(); while (e.hasMoreElements()) { key = e.nextElement(); values = request.getParameterValues(key); int length = values.length; for (int i = 0; i < length; i++) { dumpVariable(sb, key, values[i]); } } }
From source file:com.glaf.base.utils.ParamUtil.java
/** * ?/*from ww w . jav a 2s . c om*/ * * @param request * @param param * @return */ public static String[] getParameterValues(HttpServletRequest request, String param) { return request.getParameterValues(param); }
From source file:eionet.gdem.web.struts.stylesheet.AddEditStylehseetUtils.java
/** * Creates a new Stylesheet dto object and fills the properties with values inserted to web form. * @param form StylesheetForm/*from w w w.j a va2 s. c o m*/ * @param httpServletRequest HTTP servlet request object. * @return eionet.gdem.dto.Stylesheet object */ static Stylesheet convertFormToStylesheetDto(StylesheetForm form, HttpServletRequest httpServletRequest) { Stylesheet stylesheet = new Stylesheet(); stylesheet.setConvId(form.getStylesheetId()); stylesheet.setDescription(form.getDescription()); stylesheet.setType(form.getOutputtype()); stylesheet.setDependsOn(form.getDependsOn()); stylesheet.setXslFileName(form.getXslFileName()); stylesheet.setXslContent(form.getXslContent()); if (httpServletRequest.getParameterValues("newSchemas") != null) { form.setNewSchemas(httpServletRequest.getParameterValues("newSchemas")); stylesheet.setSchemaUrls(form.getNewSchemas()); } if (httpServletRequest.getParameterValues("schemaIds") != null) { stylesheet.setSchemaIds(Arrays.asList(httpServletRequest.getParameterValues("schemaIds"))); } return stylesheet; }
From source file:org.craftercms.core.util.HttpServletUtils.java
public static Map<String, Object> createRequestParamsMap(HttpServletRequest request) { Map<String, Object> paramsMap = new HashMap<String, Object>(); for (Enumeration paramNameEnum = request.getParameterNames(); paramNameEnum.hasMoreElements();) { String paramName = (String) paramNameEnum.nextElement(); String[] paramValues = request.getParameterValues(paramName); if (paramValues.length == 1) { paramsMap.put(paramName, paramValues[0]); } else {// w ww. ja v a 2 s . c o m paramsMap.put(paramName, paramValues); } } return paramsMap; }
From source file:fr.paris.lutece.util.http.SecurityUtil.java
/** * Scan request parameters to see if there no malicious code. * * @param request The HTTP request/*from ww w.j a v a 2 s. c o m*/ * @param strXssCharacters a String wich contain a list of Xss characters to check in strValue * @return true if all parameters don't contains any special characters */ public static boolean containsCleanParameters(HttpServletRequest request, String strXssCharacters) { String key; String[] values; Enumeration<String> e = request.getParameterNames(); while (e.hasMoreElements()) { key = e.nextElement(); values = request.getParameterValues(key); int length = values.length; for (int i = 0; i < length; i++) { if (SecurityUtil.containsXssCharacters(request, values[i], strXssCharacters)) { Logger logger = Logger.getLogger(LOGGER_NAME); logger.warn("SECURITY WARNING : INVALID REQUEST PARAMETERS" + dumpRequest(request)); return false; } } } return true; }
From source file:de.micromata.genome.logging.LogRequestParameterAttribute.java
/** * Fuer Logging gibt alle requestparameter in einer Zeile aus. * * @param request the request// w w w. ja va 2 s. c o m * @param excludingKeys the excluding keys * @return the request for logging */ public static String getRequestForLogging(HttpServletRequest request, String... excludingKeys) { if (request == null || request.getParameterMap().isEmpty() == true) { return "<no params>"; } StringBuilder sb = new StringBuilder(); for (Enumeration<?> en = request.getParameterNames(); en.hasMoreElements() == true;) { String s = (String) en.nextElement(); String[] values = request.getParameterValues(s); for (String v : values) { for (String exKey : excludingKeys) { if (StringUtils.equals(s, exKey) == true) { v = "****"; break; } } // for sb.append(s).append("=").append(v).append("\n"); } } return sb.toString(); }
From source file:com.glaf.base.utils.ParamUtil.java
/** * ?//from w w w.ja v a2s. c o m * * @param request * @param param * @return */ public static int[] getIntParameterValues(HttpServletRequest request, String param) { int[] ret = null; String[] s = request.getParameterValues(param); if (s != null) { ret = new int[s.length]; for (int i = 0; i < s.length; i++) { ret[i] = Integer.parseInt(s[i]); } } return ret; }
From source file:com.glaf.base.utils.ParamUtil.java
/** * ?//from w w w. j a v a2s . c om * * @param request * @param param * @return */ public static long[] getLongParameterValues(HttpServletRequest request, String param) { long[] ret = null; String[] s = request.getParameterValues(param); if (s != null) { ret = new long[s.length]; for (int i = 0; i < s.length; i++) { ret[i] = Integer.parseInt(s[i]); } } return ret; }
From source file:com.bsb.cms.commons.web.MossActionUtils.java
/** * ?? ???<s:debug></s:debug> * /*from www . java2s . c o m*/ * @param req */ @SuppressWarnings("all") @Deprecated public static void print(HttpServletRequest req) { // Application Map<String, Object> parameters = new WeakHashMap<String, Object>(); // attributes in scope RequestParameter for (Enumeration e = req.getParameterNames(); e.hasMoreElements();) { String name = (String) e.nextElement(); String[] v = req.getParameterValues(name); if (v.length == 1) { if (v[0].equals("")) continue; parameters.put(name, v[0]); } else parameters.put(name, v); } // attributes in scope Request for (Enumeration e = req.getAttributeNames(); e.hasMoreElements();) { String name = (String) e.nextElement(); Object v = req.getAttribute(name); parameters.put(name, v); } // attributes in scope Session HttpSession session = req.getSession(); for (Enumeration e = session.getAttributeNames(); e.hasMoreElements();) { String name = (String) e.nextElement(); Object v = session.getAttribute(name); parameters.put(name, v); } Set keys = parameters.keySet(); Iterator it = keys.iterator(); String key; Object value; while (it.hasNext()) { key = (String) it.next(); value = parameters.get(key); System.out.println("key:" + key + ", value:" + value); } }
From source file:com.ecbeta.common.util.JSONUtils.java
public static JSONObject toJSON(HttpServletRequest request) { MapJSONBean json = new MapJSONBean(); for (Object s : request.getParameterMap().keySet()) { for (String value : request.getParameterValues(s.toString())) { json.add(s.toString(), value); }/*ww w . jav a 2 s. c o m*/ } try { BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream())); String line; String data = ""; while ((line = br.readLine()) != null) { data += line; } data = URLDecoder.decode(data, "UTF-8"); try { JSONObject oo = JSONObject.fromObject(data); return oo; } catch (Exception ex) { Map<String, List<String>> params = parseParameters(data); for (Map.Entry<String, List<String>> entry : params.entrySet()) { for (String value : entry.getValue()) { json.add(entry.getKey(), value); } } } } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); } JSONObject job = json.toJson(); logger.info("~~~~~~~~~AutoCreating~~~~~~~~~"); logger.info(json == null ? "" : job.toString(2)); logger.info("~~~~~~~~~End~~~~~~~~~"); return job; }