Example usage for javax.servlet.http HttpServletRequest getParameterNames

List of usage examples for javax.servlet.http HttpServletRequest getParameterNames

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getParameterNames.

Prototype

public Enumeration<String> getParameterNames();

Source Link

Document

Returns an Enumeration of String objects containing the names of the parameters contained in this request.

Usage

From source file:com.doculibre.constellio.wicket.utils.SimpleParamsUtils.java

@SuppressWarnings("unchecked")
public static SimpleParams toSimpleParams(HttpServletRequest request) {
    SimpleParams params = new SimpleParams();
    Enumeration<String> paramNames = request.getParameterNames();
    while (paramNames.hasMoreElements()) {
        String paramName = (String) paramNames.nextElement();
        List<String> paramValues = Arrays.asList(request.getParameterValues(paramName));
        params.add(paramName, paramValues);
    }/*from  w ww .  jav a  2 s. c o m*/
    return params;
}

From source file:com.healthcit.analytics.dao.CouchDBDaoUtils.java

/**
 * Constructs a URL-encoded String of request parameters from a set of parameter key/value pairs.
 * @param paramKeys//  ww w  .j a v a 2  s  . c o  m
 * @param paramValues
 * @return
 */
@SuppressWarnings("unchecked")
public static String constructParameterList(HttpServletRequest request) {
    Enumeration<String> requestParamNames = request.getParameterNames();

    List<String> names = new ArrayList<String>();

    List<String> values = new ArrayList<String>();

    while (requestParamNames.hasMoreElements()) {
        String element = requestParamNames.nextElement();

        if (ArrayUtils.contains(STANDARD_COUCHDB_PARAM_NAMES, element)) {
            names.add(element);

            values.add(request.getParameter(element));
        }
    }

    StringBuffer str = new StringBuffer();

    if (names != null && names.size() == values.size()) {
        for (int i = 0; i < names.size(); ++i) {
            if (i > 0)
                str.append("&");

            String key = names.get(i);

            String value = values.get(i);

            str.append(key);

            str.append("=");

            try {
                str.append(URLEncoder.encode(value, UTF8));
            } catch (UnsupportedEncodingException e) {
            }
        }
    }
    return str.toString();
}

From source file:com.qatickets.common.HttpUtils.java

public static Map<String, String> extractParameters(HttpServletRequest req) {
    final Map<String, String> params = new HashMap<String, String>();
    final Enumeration enames = req.getParameterNames();
    while (enames.hasMoreElements()) {
        final String name = (String) enames.nextElement();
        final String value = req.getParameter(name);
        params.put(name, value);//from w  w w .j  a  v a2  s .c o m
    }
    return params;

}

From source file:ste.web.beanshell.jetty.BeanShellUtils.java

/**
 * Cleans up request variables so that they won't be set in next invocations
 *
 * @param interpreter the beanshell interpreter
 * @param request the request//from   w  ww.  j a v a  2s  .  c om
 *
 */
public static void cleanup(final Interpreter interpreter, final HttpServletRequest request) throws EvalError {
    Enumeration<String> params = request.getParameterNames();
    while (params.hasMoreElements()) {
        interpreter.unset(params.nextElement());
    }
}

From source file:mojo.view.util.DebugUtils.java

@SuppressWarnings("rawtypes")
public static void logRequestParameters(HttpServletRequest req) {
    logger.debug("REQUEST PARAMETERS");
    logger.debug("------------------");

    Enumeration enums = req.getParameterNames();

    while (enums.hasMoreElements()) {
        String paramName = (String) enums.nextElement();
        String[] paramValues = req.getParameterValues(paramName);
        StringBuilder sb = new StringBuilder();
        sb.append(paramName).append(": " + paramValues);
        logger.debug(sb.toString());/*www .  j a  va2s . c  om*/
    }

    logger.debug("");
}

From source file:de.knowwe.core.user.UserContextUtil.java

/**
 * Returns a Map<String, String> with all parameters of a http request. This
 * is necessary because the parameter map of the http request is locked.
 * /*from   w ww  . j  a va 2s. com*/
 * @created Mar 9, 2011
 * @param request the http request
 * @return map containing the parameters of the http request.
 */
public static Map<String, String> getParameters(HttpServletRequest request) {
    Map<String, String> parameters = new HashMap<>();
    if (request != null) {
        Enumeration<?> iter = request.getParameterNames();
        boolean decode = checkForFlowChart(request.getParameter("action"));
        while (iter.hasMoreElements()) {
            String key = (String) iter.nextElement();
            String value = request.getParameter(key);
            parameters.put(key, decode ? Strings.decodeURL(value) : value);
        }
        if (request.getMethod() != null && request.getMethod().equals("POST")) {

            // do not handle file uploads, leave this to the action
            if (!ServletFileUpload.isMultipartContent(request)) {

                try {
                    BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream()));

                    String line;
                    StringBuilder bob = new StringBuilder();

                    while ((line = br.readLine()) != null) {
                        bob.append(line).append("\n");
                    }

                    parameters.put("data", bob.toString());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    return parameters;
}

From source file:com.pureinfo.srm.RequestUtils.java

public static PureProperties parse(HttpServletRequest _request) throws PureException {
    logger.debug("enti");
    PureProperties props = new PureProperties();

    Enumeration names = _request.getParameterNames();
    logger.debug("enti11111111111#" + names.hasMoreElements());
    while (names.hasMoreElements()) {
        String sName = (String) names.nextElement();
        String[] values = _request.getParameterValues(sName);
        if (values.length == 1) {
            props.setProperty(sName, values[0]);
        } else {/*from  w  w  w.  j a va2s.c  o  m*/
            props.setProperty(sName, values);
        }

    }

    String sContentType = _request.getContentType();
    if (sContentType != null && sContentType.startsWith("multipart/form-data")) {
        logger.debug("enti111");
        DiskFileUpload upload = new DiskFileUpload();
        List items;
        try {
            items = upload.parseRequest(_request);
        } catch (FileUploadException ex) {
            throw new PureException(PureException.UNKNOWN, "upload error", ex);
        }
        logger.debug("enti111111111111" + items.size());
        for (Iterator iter = items.iterator(); iter.hasNext();) {
            FileItem item = (FileItem) iter.next();
            if (item.getName() == null) {
                props.setProperty(item.getFieldName(), item.getString());
            } else {
                props.setProperty(item.getFieldName(), item);
            }
            logger.debug("name:" + item.getFieldName() + "-value:" + props.getProperty(item.getFieldName()));
        }
    }

    return props;
}

From source file:ke.alphacba.cms.core.util.RequestUtils.java

/**
 * ????Map./*from   w ww .  ja  va  2s .  c om*/
 * 
 * @param request
 * @return
 */
public static Map<String, String> getParamMap(HttpServletRequest request) {
    Map<String, String> paramMap = new HashMap<String, String>();
    Enumeration<String> enume = request.getParameterNames();
    while (enume.hasMoreElements()) {
        String paramName = enume.nextElement();
        paramMap.put(paramName, request.getParameter(paramName));
    }
    return paramMap;
}

From source file:com.mobileman.projecth.web.util.ViewState.java

public static void copyViewState(HttpServletRequest request, Model model) {
    Map<String, String> postValues = new HashMap<String, String>();
    model.addAttribute("postValues", postValues);
    for (@SuppressWarnings("unchecked")
    Enumeration<String> e = request.getParameterNames(); e.hasMoreElements();) {
        String name = e.nextElement();
        String value = request.getParameter(name);
        postValues.put(name, value);/*from  w w w .ja v a2  s .  c  o m*/

        //remove later, use only postValues
        if (!name.startsWith("select") && !name.contains("password")) {
            model.addAttribute(name, value);
        }
    }
}

From source file:com.netflix.spinnaker.clouddriver.google.controllers.GoogleNamedImageLookupController.java

private static Map<String, String> extractTagFilters(HttpServletRequest httpServletRequest) {
    List<String> parameterNames = Collections.list(httpServletRequest.getParameterNames());

    return parameterNames.stream().filter(Objects::nonNull)
            .filter(parameter -> parameter.toLowerCase().startsWith("tag:"))
            .collect(Collectors.toMap(tagParameter -> tagParameter.replaceAll("tag:", "").toLowerCase(),
                    httpServletRequest::getParameter, (a, b) -> b));
}