Example usage for javax.servlet.http HttpServletRequest getParameterValues

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

Introduction

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

Prototype

public String[] getParameterValues(String name);

Source Link

Document

Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.

Usage

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());//from w  ww . jav a2s.c om
    }

    logger.debug("");
}

From source file:com.redhat.rhn.frontend.taglibs.list.ListTagHelper.java

/**
 * Returns the values of all the row items in a given list
 * This is useful for example in diff'ing between the result set
 * and the selected items on a page./*from w w  w .ja v a2 s.  c  o m*/
 * @param listName name of list
 * @param request active HttpServletRequest
 * @return string array if items found, else null
 */
public static String[] getAll(String listName, HttpServletRequest request) {
    String uniqueName = TagHelper.generateUniqueName(listName);
    String fieldParam = ListTagUtil.makePageItemsName(uniqueName);
    return request.getParameterValues(fieldParam);
}

From source file:com.ikon.util.WebUtils.java

/**
 * Extrae un parmetro de tipo String del request. Si el parmetro no existe devuelve
 * un String vacio.//  w  ww. j  a v  a 2s  .co m
 * @param request Peticin de la que extraer el parmetro.
 * @param name Nombre del parmetro
 * @return El valor String del parmetro o un String vacio si no existe.
 */
public static final List<String> getStringList(HttpServletRequest request, String name) {
    String[] value = request.getParameterValues(name);
    List<String> stringValue = new ArrayList<String>();

    if (value != null) {
        try {
            for (int i = 0; i < value.length; i++) {
                stringValue.add(new String(value[i].getBytes("ISO-8859-1"), "UTF-8"));
            }
        } catch (UnsupportedEncodingException e) {
            // Ignore
        }
    }

    return stringValue;
}

From source file:com.ikon.util.WebUtils.java

/**
 * Extrae un parmetro de tipo Integer del request. Si el parmetro no existe devuelve
 * un Integer vacio./*from ww w.  ja  v a2  s.c  o  m*/
 * @param request Peticin de la que extraer el parmetro.
 * @param name Nombre del parmetro
 * @return El valor String del parmetro o un String vacio si no existe.
 */
public static final List<Integer> getIntList(HttpServletRequest request, String name) {
    String[] value = request.getParameterValues(name);
    List<Integer> intValue = new ArrayList<Integer>();

    if (value != null) {
        try {
            for (int i = 0; i < value.length; i++) {
                intValue.add(Integer.parseInt(value[i]));
            }
        } catch (Throwable e) {
            // Ignore
        }
    }

    return intValue;
}

From source file:com.ikon.util.WebUtils.java

/**
 * Extrae un parmetro de tipo Long del request. Si el parmetro no existe devuelve
 * un Long vacio./*from w w w. j a v a2s . c  o  m*/
 * @param request Peticin de la que extraer el parmetro.
 * @param name Nombre del parmetro
 * @return El valor String del parmetro o un String vacio si no existe.
 */
public static final List<Long> getLongList(HttpServletRequest request, String name) {
    String[] value = request.getParameterValues(name);
    List<Long> intValue = new ArrayList<Long>();

    if (value != null) {
        try {
            for (int i = 0; i < value.length; i++) {
                intValue.add(Long.parseLong(value[i]));
            }
        } catch (Throwable e) {
            // Ignore
        }
    }

    return intValue;
}

From source file:com.redhat.rhn.frontend.taglibs.list.ListTagHelper.java

/**
 * Returns the values of all selected checkboxes
 * @param listName name of list/*from   www. j  ava 2s.c om*/
 * @param request active HttpServletRequest
 * @return string array if items found, else null
 */
public static String[] getSelected(String listName, HttpServletRequest request) {
    String uniqueName = TagHelper.generateUniqueName(listName);
    String fieldParam = ListTagUtil.makeSelectedItemsName(uniqueName);
    return request.getParameterValues(fieldParam);
}

From source file:architecture.ee.web.util.ParamUtils.java

public static String[] getParameters(HttpServletRequest request, String name, boolean emptyStringsOK) {
    if (name == null)
        return new String[0];
    String paramValues[] = request.getParameterValues(name);
    if (paramValues == null || paramValues.length == 0)
        return new String[0];

    List<String> values = new ArrayList<String>(paramValues.length);
    for (String value : paramValues) {
        if (value != null && (emptyStringsOK || !"".equals(value)))
            values.add(value);// w  ww. j  a v a 2s.  c o m
    }

    return values.toArray(new String[0]);
}

From source file:com.openkm.util.WebUtils.java

/**
 * Extrae un parmetro de tipo String del request. Si el parmetro no existe devuelve
 * un String vacio.//from   w  w  w .j  av  a2  s. c o m
 * @param request Peticin de la que extraer el parmetro.
 * @param name Nombre del parmetro
 * @return El valor String del parmetro o un String vacio si no existe.
 */
public static final List<String> getStringList(HttpServletRequest request, String name) {
    String[] value = request.getParameterValues(name);
    List<String> stringValue = new ArrayList<String>();

    if (value != null) {
        try {
            for (int i = 0; i < value.length; i++) {
                stringValue.add(new String(value[i].getBytes(Config.TOMCAT_CONNECTOR_URI_ENCODING), "UTF-8"));
            }
        } catch (UnsupportedEncodingException e) {
            // Ignore
        }
    }

    return stringValue;
}

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 ww  .  j a  v  a  2 s . 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:org.openmrs.module.registration.web.controller.util.RegistrationWebUtils.java

/**
 * Optimize the request's parameters//from  w ww  . j  a  v  a2  s . c  o  m
 * 
 * @param request
 * @return
 */
public static Map<String, String> optimizeParameters(HttpServletRequest request) {
    Map<String, String> parameters = new HashMap<String, String>();
    for (@SuppressWarnings("rawtypes")
    Enumeration e = request.getParameterNames(); e.hasMoreElements();) {
        String parameterName = (String) e.nextElement();
        String[] values = request.getParameterValues(parameterName);
        String value = StringUtils.join(values, ',');
        parameters.put(parameterName, value);
    }
    return parameters;
}