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:com.adobe.acs.commons.http.headers.impl.AbstractDispatcherCacheHeaderFilter.java

@SuppressWarnings("unchecked")
protected boolean accepts(final HttpServletRequest request) {

    Enumeration<String> agentsEnum = request.getHeaders(SERVER_AGENT_NAME);
    List<String> serverAgents = agentsEnum != null ? Collections.list(agentsEnum)
            : Collections.<String>emptyList();

    // Only inject when:
    // - GET request
    // - No Params
    // - From Dispatcher
    if (StringUtils.equalsIgnoreCase("get", request.getMethod()) && request.getParameterMap().isEmpty()
            && serverAgents.contains(DISPATCHER_AGENT_HEADER_VALUE)) {

        return true;
    }/*  w ww . j  ava  2  s  .com*/
    return false;
}

From source file:mx.edu.um.mateo.rh.web.CategoriaController.java

@Transactional
@RequestMapping(value = "/graba", method = RequestMethod.POST)
public String graba(HttpServletRequest request, HttpServletResponse response, @Valid Categoria categoria,
        BindingResult bindingResult, Errors errors, Model modelo, RedirectAttributes redirectAttributes) {
    for (String nombre : request.getParameterMap().keySet()) {
        log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre));
    }/*  w  w  w.j a v a2  s  .c o m*/
    if (bindingResult.hasErrors()) {
        log.debug("Hubo algun error en la forma, regresando");
        Map<String, Object> params = new HashMap<>();
        params.put("empresa", request.getSession().getAttribute("empresaId"));
        params.put("reporte", true);
        return Constantes.PATH_CATEGORIA_NUEVO;
    }

    try {
        Usuario usuario = ambiente.obtieneUsuario();
        categoriaManager.graba(categoria, usuario);
    } catch (ConstraintViolationException e) {
        log.error("No se pudo grabar categoria", e);
        return Constantes.PATH_CATEGORIA_NUEVO;
    } catch (Exception ex) {
        log.error("Nuevo Falla");
        log.debug("Nuevo Falla");
        return Constantes.PATH_CATEGORIA_NUEVO;

    }

    redirectAttributes.addFlashAttribute(Constantes.CONTAINSKEY_MESSAGE, "categoria.graba.message");
    redirectAttributes.addFlashAttribute(Constantes.CONTAINSKEY_MESSAGE_ATTRS,
            new String[] { categoria.getNombre() });

    return "redirect:" + Constantes.PATH_CATEGORIA_LISTA + "/";
}

From source file:org.apache.wink.test.mock.MockHttpServletRequestWrapperTestCase.java

@Test
public void testParameter() throws Exception {
    HttpServletRequest req = MockRequestConstructor.constructMockRequest("POST", "/test", "application/json",
            "application/x-www-form-urlencoded", "x=1&y=2&z=%20".getBytes("UTF-8"));
    String x = req.getParameter("x");
    String y = req.getParameter("y");
    String z = req.getParameter("z");
    String a = req.getParameter("a");

    Assert.assertEquals("1", x);
    Assert.assertEquals("2", y);
    Assert.assertEquals(" ", z);
    Assert.assertNull(a);/*from w  ww  . ja  v a  2  s .  co m*/

    Assert.assertEquals(3, req.getParameterMap().size());
}

From source file:org.iqvis.nvolv3.request.filter.LoggingFilter.java

private void logResponse(final ResponseWrapper response, final HttpServletRequest request, long elapsed) {
    StringBuilder msg = new StringBuilder();

    Gson gson = new Gson();

    // msg.append(RESPONSE_PREFIX);
    // msg.append("request id=").append((response.getId()));
    msg.append("").append((response.getId()));

    msg.append("|").append(elapsed);

    msg.append("|").append(request.getRequestURI());

    try {/*ww w. ja  va2  s. c  om*/

        msg.append("|").append(gson.toJson(request.getParameterMap()));

    } catch (Exception e) {

    }

    // try {

    // msg.append("; payload=").append(new String(response.toByteArray(),
    // response.getCharacterEncoding()));

    // } catch (UnsupportedEncodingException e) {
    // logger.warn("Failed to parse response payload", e);
    // }
    logger.debug(msg.toString());
}

From source file:com.yoshio3.modules.AzureADServerAuthModule.java

public boolean isRedirectedRequestFromAuthServer(HttpServletRequest httpRequest, Map<String, String> params) {
    return httpRequest.getMethod().equalsIgnoreCase("POST") && (httpRequest.getParameterMap().containsKey(ERROR)
            || httpRequest.getParameterMap().containsKey(ID_TOKEN)
            || httpRequest.getParameterMap().containsKey(CODE));
}

From source file:mx.edu.um.mateo.rh.web.JefeSeccionController.java

@Transactional
@RequestMapping(value = "/graba", method = RequestMethod.POST)
public String graba(HttpServletRequest request, HttpServletResponse response, @Valid JefeSeccion jefeSeccion,
        BindingResult bindingResult, Errors errors, Model modelo, RedirectAttributes redirectAttributes) {
    for (String nombre : request.getParameterMap().keySet()) {
        log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre));
    }//from   w w w.j  ava2s  .co  m
    if (bindingResult.hasErrors()) {
        log.debug("Hubo algun error en la forma, regresando");
        return Constantes.PATH_JEFESECCION_NUEVO;
    }
    log.debug("jefesecicion.jefeseccion{}", jefeSeccion.getJefeSeccion().getNombre());
    Usuario usuario = ambiente.obtieneUsuario();
    Empleado empleado = (Empleado) request.getSession().getAttribute(Constantes.EMPLEADO_KEY);
    jefeSeccion.setFechaAlta(new Date());
    jefeSeccion.setUsuarioAlta(usuario);
    ArrayList ids = new ArrayList();
    Enumeration<String> parameterNames = request.getParameterNames();
    while (parameterNames.hasMoreElements()) {
        String nombre = parameterNames.nextElement();

        if (nombre.startsWith("checkJefe")) {
            String[] id = nombre.split("-");
            log.debug("id ={}", id[1]);
            ids.add(id[1]);
        }
    }
    try {
        manager.graba(jefeSeccion, usuario, ids);
    } catch (ConstraintViolationException e) {
        log.error("No se pudo crear nacionalidad", e);
        return Constantes.PATH_JEFESECCION_NUEVO;
    }

    redirectAttributes.addFlashAttribute(Constantes.CONTAINSKEY_MESSAGE, "jefeSeccion.graba.message");
    redirectAttributes.addFlashAttribute(Constantes.CONTAINSKEY_MESSAGE_ATTRS,
            new String[] { jefeSeccion.getJefeSeccion().getNombre() });

    return "redirect:" + Constantes.PATH_JEFESECCION_LISTA + "/";
}

From source file:fr.mby.portal.coreimpl.action.BasicUserActionFactory.java

@Override
@SuppressWarnings("unchecked")
public IUserAction build(final HttpServletRequest request) {
    Assert.notNull(request, "No HTTP request provided !");

    final IPortalContext portalContext = this.portalContextResolver.resolve(request);
    final IUserDetails userDetails = this.userDetailsResolver.resolve(request);
    final String portalSessionId = this.sessionManager.getPortalSessionId(request);
    final Map<String, Iterable<String>> properties = this.requestPropertiesResolver.resolve(request);
    final Map<String, String[]> parameters = request.getParameterMap();
    final Map<String, Object> attributes = this.extractAttributes(request);

    final BasicUserAction userAction = new BasicUserAction(portalContext, userDetails, portalSessionId,
            properties, parameters, attributes);

    return userAction;
}

From source file:mx.edu.um.mateo.rh.web.VacacionesEmpleadoController.java

@Transactional
@RequestMapping(value = "/graba", method = RequestMethod.POST)
public String graba(HttpServletRequest request, HttpServletResponse response,
        @Valid VacacionesEmpleado vacacionesEmpleado, BindingResult bindingResult, Errors errors, Model modelo,
        RedirectAttributes redirectAttributes) {
    for (String nombre : request.getParameterMap().keySet()) {
        log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre));
    }/*from   w  ww .jav a2s .  com*/
    if (bindingResult.hasErrors()) {
        log.debug("Hubo algun error en la forma, regresando");
        return Constantes.PATH_VACACIONESEMPLEADO_NUEVO;
    }

    try {
        Enumeration<String> r = request.getSession().getAttributeNames();
        while (r.hasMoreElements()) {
            log.debug("nombre{}", r.nextElement());
        }
        Usuario usuario = ambiente.obtieneUsuario();
        manager.graba(vacacionesEmpleado, usuario);
    } catch (ConstraintViolationException e) {
        log.error("No se pudo crear dia feriado", e);
        return Constantes.PATH_VACACIONESEMPLEADO_NUEVO;
    }

    redirectAttributes.addFlashAttribute(Constantes.CONTAINSKEY_MESSAGE, "vacacionesEmpleado.graba.message");
    redirectAttributes.addFlashAttribute(Constantes.CONTAINSKEY_MESSAGE_ATTRS,
            new String[] { vacacionesEmpleado.getDescripcion() });

    return "redirect:" + Constantes.PATH_VACACIONESEMPLEADO_LISTA + "/";
}

From source file:mx.edu.um.mateo.inventario.web.FacturaAlmacenController.java

@RequestMapping(value = "/buscaSalida", params = "term", produces = "application/json")
public @ResponseBody List<LabelValueBean> buscaSalida(HttpServletRequest request,
        @RequestParam("term") String filtro, @RequestParam("facturaId") Long facturaId) {
    for (String nombre : request.getParameterMap().keySet()) {
        log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre));
    }/*  w  w w. ja va 2  s .c om*/
    Map<String, Object> params = new HashMap<>();
    params.put("almacen", request.getSession().getAttribute("almacenId"));
    params.put("filtro", filtro);
    params.put("facturaId", facturaId);
    List<Salida> salidas = salidaDao.buscaSalidasParaFactura(params);
    List<LabelValueBean> valores = new ArrayList<>();
    for (Salida salida : salidas) {
        StringBuilder sb = new StringBuilder();
        sb.append(salida.getFolio());
        sb.append(" | ");
        sb.append(salida.getCliente().getNombre());
        valores.add(new LabelValueBean(salida.getId(), sb.toString(), salida.getFolio()));
    }
    return valores;
}

From source file:mx.edu.um.mateo.inventario.web.FacturaAlmacenController.java

@RequestMapping(value = "/buscaEntrada", params = "term", produces = "application/json")
public @ResponseBody List<LabelValueBean> buscaEntrada(HttpServletRequest request,
        @RequestParam("term") String filtro, @RequestParam("facturaId") Long facturaId) {
    for (String nombre : request.getParameterMap().keySet()) {
        log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre));
    }// ww  w. ja  v  a2 s .co  m
    Map<String, Object> params = new HashMap<>();
    params.put("almacen", request.getSession().getAttribute("almacenId"));
    params.put("filtro", filtro);
    params.put("facturaId", facturaId);
    List<Entrada> entradas = entradaDao.buscaEntradasParaFactura(params);
    List<LabelValueBean> valores = new ArrayList<>();
    for (Entrada entrada : entradas) {
        StringBuilder sb = new StringBuilder();
        sb.append(entrada.getFolio());
        sb.append(" | ");
        sb.append(entrada.getProveedor().getNombre());
        valores.add(new LabelValueBean(entrada.getId(), sb.toString(), entrada.getFolio()));
    }
    return valores;
}