Example usage for javax.servlet.http HttpServletRequest getParameterMap

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

Introduction

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

Prototype

public Map<String, String[]> getParameterMap();

Source Link

Document

Returns a java.util.Map of the parameters of this request.

Usage

From source file:ar.com.zauber.commons.facebook.utils.impl.DefaultCallbackRequestValidator.java

/**
 * @param request/*from w w w .  ja  va2  s  . com*/
 * @return
 */
public static Map<String, String> extractFacebookParams(final HttpServletRequest request) {
    final Map<String, String> params = new HashMap<String, String>();
    final Map tmp = FacebookSignatureUtil.extractFacebookNamespaceParams(request.getParameterMap());
    Set<Entry<String, Object>> s = tmp.entrySet();
    // el jetty pasa los parametros como arreglos. y facebook no se la banca
    for (final Entry<String, Object> entry : s) {
        if (entry.getValue().getClass().isArray()) {
            params.put(entry.getKey(), ((String[]) entry.getValue())[0]);
        } else {
            params.put(entry.getKey(), entry.getKey());
        }
    }
    return params;
}

From source file:com.concursive.connect.web.modules.wiki.utils.CustomFormUtils.java

/**
 * Creates the wiki content when creating a new wiki from a template that has a form
 *
 * @param template//  w w  w.  j  a v  a  2 s  .c  o m
 * @param request
 * @return
 * @throws Exception
 */
public static String populateForm(WikiTemplate template, HttpServletRequest request) throws Exception {
    return populateForm(template.getContent(), request.getParameterMap());
}

From source file:com.concursive.connect.web.modules.wiki.utils.CustomFormUtils.java

/**
 * Updates a wiki with the entered values of the form presented to a wiki user
 *
 * @param wiki/*from  ww  w. j a  va2s.com*/
 * @param request
 * @throws Exception
 */
public static void populateForm(Wiki wiki, HttpServletRequest request) throws Exception {
    wiki.setContent(populateForm(wiki.getContent(), request.getParameterMap()));
}

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

public static Map getParametersAsMap(HttpServletRequest request) {
    return request.getParameterMap();
}

From source file:com.vmware.identity.openidconnect.common.HttpRequest.java

public static HttpRequest create(HttpServletRequest httpServletRequest) {
    Validate.notNull(httpServletRequest, "httpServletRequest");

    Map<String, String> parameters = new HashMap<String, String>();
    for (Map.Entry<String, String[]> entry : httpServletRequest.getParameterMap().entrySet()) {
        parameters.put(entry.getKey(), entry.getValue()[0]); // just take the first value
    }/*from ww  w . j a  v  a2 s . co  m*/

    String requestUrlString = httpServletRequest.getRequestURL().toString();
    URL requestUrl;
    try {
        requestUrl = new URL(requestUrlString);
    } catch (MalformedURLException e) {
        // this should not happen since the URL is formed off of httpServletRequest.getRequestURL()
        throw new IllegalArgumentException(e);
    }
    URI requestUri = URI.create(requestUrlString);

    return new HttpRequest(httpServletRequest, parameters, requestUrl, requestUri);
}

From source file:de.thorstenberger.taskmodel.view.SavePageAction.java

public static void logPostData(final HttpServletRequest request, final Tasklet tasklet) {
    final Map vars = request.getParameterMap();
    final StringBuffer parameters = new StringBuffer();
    final Iterator keys = vars.keySet().iterator();
    while (keys.hasNext()) {
        final String key = (String) keys.next();
        parameters.append(key + "=" + ((String[]) vars.get(key))[0] + "\n");
    }//from  ww w . j  a v a2 s .com
    tasklet.logPostData("posted parameters:\n" + parameters.toString(), request.getRemoteAddr());
}

From source file:org.apache.atlas.web.util.Servlets.java

public static Map<String, Object> getParameterMap(HttpServletRequest request) {
    Map<String, Object> attributes = new HashMap<>();

    if (MapUtils.isNotEmpty(request.getParameterMap())) {
        for (Map.Entry<String, String[]> e : request.getParameterMap().entrySet()) {
            String key = e.getKey();

            if (key != null) {
                String[] values = e.getValue();
                String value = values != null && values.length > 0 ? values[0] : null;

                attributes.put(key, value);
            }//from  w  w w  .j  av a 2  s .c  o m
        }
    }

    return attributes;
}

From source file:fr.paris.lutece.plugins.stock.modules.billetterie.web.AbstractXPageApp.java

/**
 * Populate a bean using parameters in http request
 *
 * @param bean bean to populate//w  ww. j  a  va 2 s. co  m
 * @param request http request
 */
protected static void populate(Object bean, HttpServletRequest request) {
    try {
        BeanUtils.populate(bean, request.getParameterMap());
    } catch (IllegalAccessException e) {
        LOGGER.error(POPULATE_ERROR_MESSAGE, e);
    } catch (InvocationTargetException e) {
        LOGGER.error(POPULATE_ERROR_MESSAGE, e);
    }
}

From source file:eu.europeana.core.util.web.ControllerUtil.java

@SuppressWarnings("unchecked")
public static String formatFullRequestUrl(HttpServletRequest request) {
    StringBuffer requestURL = request.getRequestURL();
    if (request.getQueryString() != null) {
        requestURL.append("?").append(request.getQueryString());
    } else if (request.getParameterMap() != null) {
        requestURL.append(formatParameterMapAsQueryString(request.getParameterMap()));
    }/*from  w  w w .  j  a  va2s  .c  om*/
    return requestURL.toString();
}

From source file:com.ai.smart.common.helper.util.RequestUtils.java

public static Map<String, Object> getQueryParams(HttpServletRequest request) {
    Map<String, String[]> map;
    if (request.getMethod().equalsIgnoreCase(POST)) {
        map = request.getParameterMap();
    } else {/*w  w w  .j a va  2  s . c  o  m*/
        String s = request.getQueryString();
        if (StringUtils.isBlank(s)) {
            return new HashMap<String, Object>();
        }
        try {
            s = URLDecoder.decode(s, UTF8);
        } catch (UnsupportedEncodingException e) {
            log.error("encoding " + UTF8 + " not support?", e);
        }
        map = parseQueryString(s);
    }

    Map<String, Object> params = new HashMap<String, Object>(map.size());
    int len;
    for (Map.Entry<String, String[]> entry : map.entrySet()) {
        len = entry.getValue().length;
        if (len == 1) {
            params.put(entry.getKey(), entry.getValue()[0]);
        } else if (len > 1) {
            params.put(entry.getKey(), entry.getValue());
        }
    }
    return params;
}