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:mx.edu.um.mateo.general.web.AsociacionController.java

@RequestMapping(value = "/crea", method = RequestMethod.POST)
public String crea(HttpServletRequest request, HttpServletResponse response, @Valid Asociacion asociacion,
        BindingResult bindingResult, Errors errors, Model modelo, RedirectAttributes redirectAttributes) {
    for (String nombre : request.getParameterMap().keySet()) {
        log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre));
    }//from   ww  w . jav a2  s  .c o  m
    if (bindingResult.hasErrors()) {
        log.debug("Hubo algun error en la forma, regresando");
        for (ObjectError error : bindingResult.getAllErrors()) {
            log.debug("Error: {}", error);
        }
        return Constantes.PATH_ASOCIACION_NUEVA;
    }
    try {
        Usuario usuario = null;
        if (ambiente.obtieneUsuario() != null) {
            usuario = ambiente.obtieneUsuario();
        }
        asociacion = asociacionDao.crea(asociacion, usuario);
        ambiente.actualizaSesion(request, usuario);
    } catch (ConstraintViolationException e) {
        log.error("No se pudo crear al Asociacion", e);
        errors.rejectValue("nombre", "campo.duplicado.message", new String[] { "nombre" }, null);
        return Constantes.PATH_ASOCIACION_NUEVA;
    }
    redirectAttributes.addFlashAttribute(Constantes.CONTAINSKEY_MESSAGE, "asociacion.creada.message");
    redirectAttributes.addFlashAttribute(Constantes.CONTAINSKEY_MESSAGE_ATTRS,
            new String[] { asociacion.getNombre() });
    return "redirect:" + Constantes.PATH_ASOCIACION_VER + "/" + asociacion.getId();
}

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

@RequestMapping(value = "/graba", method = RequestMethod.POST)
public String graba(HttpServletRequest request, HttpServletResponse response, @Valid Empleado empleado,
        BindingResult bindingResult, Errors errors, Model modelo, RedirectAttributes redirectAttributes) {
    for (String nombre : request.getParameterMap().keySet()) {
        log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre));
    }//from  ww  w  .  j  a  v  a  2 s .co m
    if (bindingResult.hasErrors()) {
        log.debug("Hubo algun error en la forma, regresando");
        for (ObjectError error : bindingResult.getAllErrors()) {
            log.debug("Error: {}", error);
        }
        return Constantes.PATH_EMPLEADO_NUEVO;
    }

    try {
        Usuario usuario = ambiente.obtieneUsuario();
        empleadoManager.saveEmpleado(empleado, usuario);

        ambiente.actualizaSesion(request.getSession(), usuario);
    } catch (ConstraintViolationException e) {
        log.error("No se pudo crear al empleado", e);
        errors.rejectValue("nombre", "empleado.errors.creado", e.toString());
        return Constantes.PATH_EMPLEADO_NUEVO;
    }

    redirectAttributes.addFlashAttribute("message", "empleado.creado.message");
    redirectAttributes.addFlashAttribute("messageAttrs", new String[] { empleado.getNombre() });

    return "redirect:" + Constantes.PATH_EMPLEADO;
}

From source file:org.openmrs.module.OpenmrsLite.fragment.controller.MatchingPatientsFragmentController.java

public List<SimpleObject> getSimilarPatients(@RequestParam("appId") AppDescriptor app,
        @SpringBean("registrationCoreService") RegistrationCoreService service,
        @ModelAttribute("patient") @BindParams Patient patient,
        @ModelAttribute("personName") @BindParams PersonName name,
        @ModelAttribute("personAddress") @BindParams PersonAddress address, HttpServletRequest request,
        UiUtils ui) throws Exception {
    NavigableFormStructure formStructure = RegisterPatientFormBuilder.buildFormStructure(app);

    patient.addName(name);// w  ww .ja v  a2  s  .co m
    patient.addAddress(address);

    if (formStructure != null) {
        RegisterPatientFormBuilder.resolvePersonAttributeFields(formStructure, patient,
                request.getParameterMap());
    }

    List<PatientAndMatchQuality> matches = service.findFastSimilarPatients(patient, null, 2.0, 10);

    List<Patient> similarPatients = new ArrayList<Patient>();
    for (PatientAndMatchQuality match : matches) {
        similarPatients.add(match.getPatient());
    }

    String[] propertiesToInclude = new String[] { "patientId", "givenName", "familyName",
            "patientIdentifier.identifier", "gender", "birthdate", "personAddress" };

    return SimpleObject.fromCollection(similarPatients, ui, propertiesToInclude);
}

From source file:com.carlos.projects.billing.ui.controllers.AddComponentsController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    ModelAndView modelAndView = super.handleRequestInternal(request, response);
    modelAndView.getModelMap().addAttribute("familyName", request.getParameter("familyName"));
    modelAndView.getModelMap().addAttribute("document",
            getDocumentWithComponentsAdded(request.getParameterMap()));
    return modelAndView;
}

From source file:de.mpg.imeji.presentation.servlet.ExportServlet.java

/**
 * {@inheritDoc}//from  w  w  w  .jav a 2s. c  om
 */
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    SessionBean session = getSessionBean(req, resp);
    String instanceName = session.getInstanceName();
    User user = session.getUser();
    try {
        ExportManager exportManager = new ExportManager(resp.getOutputStream(), user, req.getParameterMap());
        String exportName = instanceName + "_";
        exportName += new Date().toString().replace(" ", "_").replace(":", "-");
        if (exportManager.getContentType().equalsIgnoreCase("application/xml")) {
            exportName += ".xml";
        }
        if (exportManager.getContentType().equalsIgnoreCase("application/zip")) {
            exportName += ".zip";
        }
        resp.setHeader("Connection", "close");
        resp.setHeader("Content-Type", exportManager.getContentType());
        resp.setHeader("Content-disposition", "filename=" + exportName);
        resp.setStatus(HttpServletResponse.SC_OK);
        SearchResult result = exportManager.search();
        exportManager.export(result);
        resp.getOutputStream().flush();
    } catch (HttpResponseException he) {
        resp.sendError(he.getStatusCode(), he.getMessage());
    } catch (Exception e) {
        resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
    }
}

From source file:mx.edu.um.mateo.colportor.web.ClienteColportorController.java

@RequestMapping(value = "/crea", method = RequestMethod.POST)
public String crea(HttpServletRequest request, HttpServletResponse response,
        @Valid ClienteColportor clienteColportor, BindingResult bindingResult, Errors errors, Model modelo,
        RedirectAttributes redirectAttributes) {
    for (String nombre : request.getParameterMap().keySet()) {
        log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre));
    }/*from   ww  w .  ja v  a  2s .  c om*/
    if (bindingResult.hasErrors()) {
        log.debug("Hubo algun error en la forma, regresando");
        return Constantes.CLIENTE_COLPORTOR_PATH_NUEVO;
    }

    try {
        //Se supone que el colportor lo registra
        Usuario usuario = ambiente.obtieneUsuario();
        clienteColportor.setEmpresa(usuario.getEmpresa());
        clienteColportor.setStatus(Constantes.STATUS_ACTIVO);
        clienteColportor = clienteColportorDao.crea(clienteColportor);
    } catch (ConstraintViolationException e) {
        log.error("No se pudo crear al clienteColportor", e);
        return Constantes.CLIENTE_COLPORTOR_PATH_NUEVO;
    }

    redirectAttributes.addFlashAttribute("message", "clienteColportor.creado.message");
    redirectAttributes.addFlashAttribute("messageAttrs", new String[] { clienteColportor.getNombre() });

    return "redirect:" + Constantes.CLIENTE_COLPORTOR_PATH_VER + "/" + clienteColportor.getId();
}

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

@RequestMapping(value = "/crea", method = RequestMethod.POST)
public String crea(HttpServletRequest request, HttpServletResponse response, @Valid TipoEmpleado tipoEmpleado,
        BindingResult bindingResult, Errors errors, Model modelo, RedirectAttributes redirectAttributes) {
    for (String nombre : request.getParameterMap().keySet()) {
        log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre));
    }/*from  ww  w  . ja v  a2s . c  o m*/
    if (bindingResult.hasErrors()) {
        log.debug("Hubo algun error en la forma, regresando");

        return Constantes.PATH_TIPOEMPLEADO_NUEVO;
    }

    try {
        Usuario usuario = ambiente.obtieneUsuario();
        log.debug("TipoCliente: {}", tipoEmpleado.getId());
        tipoEmpleado = tipoEmpleadoMgr.crea(tipoEmpleado, usuario);
    } catch (ConstraintViolationException e) {
        log.error("No se pudo crear al tipo empleado", e);
        errors.rejectValue("descripcion", "campo.duplicado.message", new String[] { "descripcion" }, null);

        return Constantes.PATH_TIPOEMPLEADO_NUEVO;
    }

    redirectAttributes.addFlashAttribute("message", "cliente.creado.message");
    redirectAttributes.addFlashAttribute("messageAttrs", new String[] { tipoEmpleado.getDescripcion() });

    return "redirect:" + Constantes.PATH_TIPOEMPLEADO_VER + "/" + tipoEmpleado.getId();
}

From source file:de.hybris.platform.chinesepspalipaymockaddon.controllers.pages.AlipayMockController.java

protected void doPaymentStatus(final HttpServletRequest request, final HttpServletResponse response)
        throws IOException {
    final Map<String, String[]> requestParamMap = request.getParameterMap();
    if (requestParamMap == null) {
        return;/*from  w w  w.  j  a va2 s. c o m*/
    }
    final Map<String, String> clearParams = removeUselessValue(requestParamMap);
    this.setCSRFToken(clearParams, request);

    if (isSignValid(clearParams)) {
        final String result = mockService.getPaymentStatusRequest(clearParams);
        response.getWriter().print(result);
    }
}

From source file:grails.web.servlet.mvc.GrailsParameterMap.java

/**
 * Creates a GrailsParameterMap populating from the given request object
 * @param request The request object//ww  w.  j a  v a2  s.c  o m
 */
public GrailsParameterMap(HttpServletRequest request) {
    this.request = request;
    final Map requestMap = new LinkedHashMap(request.getParameterMap());
    if (requestMap.isEmpty() && ("PUT".equals(request.getMethod()) || "PATCH".equals(request.getMethod()))
            && request.getAttribute(REQUEST_BODY_PARSED) == null) {
        // attempt manual parse of request body. This is here because some containers don't parse the request body automatically for PUT request
        String contentType = request.getContentType();
        if ("application/x-www-form-urlencoded".equals(contentType)) {
            try {
                Reader reader = request.getReader();
                if (reader != null) {
                    String contents = IOUtils.toString(reader);
                    request.setAttribute(REQUEST_BODY_PARSED, true);
                    requestMap.putAll(WebUtils.fromQueryString(contents));
                }
            } catch (Exception e) {
                LOG.error("Error processing form encoded " + request.getMethod() + " request", e);
            }
        }
    }

    if (request instanceof MultipartHttpServletRequest) {
        Map<String, MultipartFile> fileMap = ((MultipartHttpServletRequest) request).getFileMap();
        for (Map.Entry<String, MultipartFile> entry : fileMap.entrySet()) {
            requestMap.put(entry.getKey(), entry.getValue());
        }
    }

    updateNestedKeys(requestMap);
}

From source file:de.hybris.platform.chinesepspalipaymockaddon.controllers.pages.AlipayMockController.java

protected void doCancelPayment(final HttpServletRequest request, final HttpServletResponse response)
        throws IOException {

    final Map<String, String[]> requestParamMap = request.getParameterMap();
    if (requestParamMap == null) {
        return;/*  ww w.ja v a2  s.  c o m*/
    }
    final Map<String, String> clearParams = removeUselessValue(requestParamMap);
    this.setCSRFToken(clearParams, request);

    if (isSignValid(clearParams)) {
        final String result = mockService.getCancelPaymentRequest();
        response.getWriter().print(result);
    }
}