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:de.hybris.platform.chinesepspalipaymockaddon.controllers.pages.AlipayMockController.java

@RequestMapping(value = "/doRefund", method = RequestMethod.GET)
public @ResponseBody String doRefund(final Model model, 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> requestType = createRequestTypeMap(requestParamMap);
    final Map<String, String> clearParams = removeUselessValue(requestParamMap);
    final String errorCode = XSSFilterUtil.filter(requestType.get("error_code"));
    this.setCSRFToken(clearParams, request);
    final String url = clearParams.get("notify_url");
    final Map<String, String> notify = mockService.getRefundNotifyParams(clearParams, errorCode);
    mockService.sendPostInfo(notify, url);

    final String action = request.getParameter("action");
    if (action == null) {
        return "";
    }
    String resultMessage = "";
    if ("notify".equals(action)) {
        resultMessage = "Refund Finished!";
    }
    return resultMessage;
}

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

@RequestMapping(value = "/crea", method = RequestMethod.POST)
public String crea(HttpServletRequest request, HttpServletResponse response,
        @Valid ReciboColportor reciboColportor, 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 a2s  .c  om
    if (bindingResult.hasErrors()) {
        log.debug("Hubo algun error en la forma, regresando");

        return Constantes.RECIBO_COLPORTOR_PATH_NUEVO;
    }

    try {
        //Se supone que el colportor lo registra
        Usuario usuario = ambiente.obtieneUsuario();
        reciboColportor.setPedido(pedidoColportorDao.obtiene(
                ((PedidoColportor) request.getSession().getAttribute(Constantes.PEDIDO_COLPORTOR)).getId()));
        reciboColportor.setStatus(Constantes.STATUS_ACTIVO);
        reciboColportor = reciboColportorDao.crea(reciboColportor);
    } catch (ConstraintViolationException e) {
        log.error("No se pudo crear al reciboColportor", e);

        return Constantes.RECIBO_COLPORTOR_PATH_NUEVO;
    }

    redirectAttributes.addFlashAttribute("message", "reciboColportor.creado.message");
    redirectAttributes.addFlashAttribute("messageAttrs",
            new String[] { reciboColportor.getNumRecibo().toString() });

    return "redirect:" + Constantes.RECIBO_COLPORTOR_PATH_VER + "/" + reciboColportor.getId();
}

From source file:com.priocept.jcr.server.UploadServlet.java

private void processFiles(HttpServletRequest request, HttpServletResponse response) {
    HashMap<String, String> args = new HashMap<String, String>();
    try {//from w w w. j  a  va  2  s.c o m
        if (log.isDebugEnabled())
            log.debug(request.getParameterMap());
        ServletFileUpload upload = new ServletFileUpload();
        FileItemIterator iter = upload.getItemIterator(request);
        // pick up parameters first and note actual FileItem
        while (iter.hasNext()) {
            FileItemStream item = iter.next();
            String name = item.getFieldName();
            if (item.isFormField()) {
                args.put(name, Streams.asString(item.openStream()));
            } else {
                args.put("contentType", item.getContentType());
                String fileName = item.getName();
                int slash = fileName.lastIndexOf("/");
                if (slash < 0)
                    slash = fileName.lastIndexOf("\\");
                if (slash > 0)
                    fileName = fileName.substring(slash + 1);
                args.put("fileName", fileName);

                if (log.isDebugEnabled())
                    log.debug(args);

                InputStream in = null;
                try {
                    in = item.openStream();
                    writeToFile(request.getSession().getId() + "/" + fileName, in, true,
                            request.getSession().getServletContext().getRealPath("/"));
                } catch (Exception e) {
                    //                  e.printStackTrace();
                    log.error("Fail to upload " + fileName);

                    response.setContentType("text/html");
                    response.setHeader("Pragma", "No-cache");
                    response.setDateHeader("Expires", 0);
                    response.setHeader("Cache-Control", "no-cache");
                    PrintWriter out = response.getWriter();
                    out.println("<html>");
                    out.println("<body>");
                    out.println("<script type=\"text/javascript\">");
                    out.println("if (parent.uploadFailed) parent.uploadFailed('"
                            + e.getLocalizedMessage().replaceAll("\'|\"", "") + "');");
                    out.println("</script>");
                    out.println("</body>");
                    out.println("</html>");
                    out.flush();
                    return;
                } finally {
                    if (in != null)
                        try {
                            in.close();
                        } catch (Exception e) {
                        }
                }

            }
        }
        response.setContentType("text/html");
        response.setHeader("Pragma", "No-cache");
        response.setDateHeader("Expires", 0);
        response.setHeader("Cache-Control", "no-cache");
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<body>");
        out.println("<script type=\"text/javascript\">");
        out.println("if (parent.uploadComplete) parent.uploadComplete('" + args.get("fileName") + "');");
        out.println("</script>");
        out.println("</body>");
        out.println("</html>");
        out.flush();
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}

From source file:com.comcast.cqs.controller.CQSPeekMessageAction.java

@Override
public boolean doAction(User user, AsyncContext asyncContext) throws Exception {

    HttpServletRequest request = (HttpServletRequest) asyncContext.getRequest();
    HttpServletResponse response = (HttpServletResponse) asyncContext.getResponse();

    CQSQueue queue = CQSCache.getCachedQueue(user, request);
    List<CQSMessage> messageList = getMessages(request, true, queue);

    Map<String, String[]> requestParams = request.getParameterMap();
    List<String> filterAttributes = new ArrayList<String>();
    List<String> filterMessageAttributes = new ArrayList<String>();

    for (String k : requestParams.keySet()) {
        if (k.contains(CQSConstants.MESSAGE_ATTRIBUTE_NAME)) {
            filterMessageAttributes.add(requestParams.get(k)[0]);
        } else if (k.contains(CQSConstants.ATTRIBUTE_NAME)) {
            filterAttributes.add(requestParams.get(k)[0]);
        }/*  www .j  a v  a2s.  com*/
    }

    String out = CQSMessagePopulator.getReceiveMessageResponseAfterSerializing(messageList, filterAttributes,
            filterMessageAttributes);
    writeResponse(out, response);

    return messageList == null ? false : true;
}

From source file:eu.cloudscale.showcase.servlets.PaymentController.java

@RequestMapping(value = "", method = RequestMethod.GET)
public String get(HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) {
    HttpSession session = super.getHttpSession(BuyConfirmController.class, request);
    ArrayList<String> errors = new ArrayList<String>();

    redirectAttrsMap.putAll(request.getParameterMap());

    String shoppingIdString = request.getParameter("SHOPPING_ID");
    Integer shoppingId = null;//from   w  ww . j  a v  a 2 s .c  o  m
    if (shoppingIdString != null && !shoppingIdString.isEmpty()) {
        shoppingId = Integer.parseInt(shoppingIdString);
    }

    String customerIdString = request.getParameter("C_ID");
    Integer customerId = null;
    if (customerIdString != null && !customerIdString.isEmpty()) {
        customerId = Integer.parseInt(customerIdString);
    }

    String ccType = request.getParameter("CC_TYPE");
    String ccNumber_str = request.getParameter("CC_NUMBER");
    Long ccNumber = null;
    if (!ccNumber_str.isEmpty())
        ccNumber = Long.parseLong(ccNumber_str);

    SimpleDateFormat sdf = new SimpleDateFormat("mm/dd/yyyy");
    String ccName = request.getParameter("CC_NAME");
    Date ccExpiry = null;
    try {
        ccExpiry = sdf.parse(request.getParameter("CC_EXPIRY"));
    } catch (ParseException e) {
        e.printStackTrace();
    }
    String shipping = request.getParameter("SHIPPING");
    String street1 = request.getParameter("street1");

    BuyConfirmResult res = null;
    if (street1 != null && street1.equals("")) {
        checkEmptiness(errors, shoppingId, customerId, ccType, ccNumber, ccName, ccExpiry, shipping);
    } else {
        String street2 = request.getParameter("street2");
        String city = request.getParameter("city");
        String state = request.getParameter("state");
        String zip = request.getParameter("zip");
        String country = request.getParameter("country");
        checkEmptiness(errors, shoppingId, customerId, ccType, ccNumber, ccName, ccExpiry, shipping, street1,
                country, city, state, zip);
    }

    String distribution = request.getParameter("distribution");
    String attr1 = request.getParameter("attr1");
    String attr2 = request.getParameter("attr2");
    String attr3 = request.getParameter("attr3");

    if (distribution != null && (attr1 == null || attr2 == null || attr3 == null)) {
        errors.add("You provided 'distribution' parameter but not 'attr1', 'attr2' or 'attr3'");
    }

    if (distribution == null) {
        errors.add("You must provide 'distribution' parameter! See " + paymentService.BASE_URL
                + " for more info.");
    }

    model.addAttribute("errors", errors);
    model.addAttribute("results", res);
    setupFrontend(model, shoppingId, customerId);

    if (errors.isEmpty()) {
        paymentResult = paymentService.callPaymentService(distribution, attr1, attr2, attr3);
    }

    return "payment";

}

From source file:com.smartgwt.extensions.fileuploader.server.ProjectServlet.java

private void processFiles(HttpServletRequest request, HttpServletResponse response) {
    HashMap<String, String> args = new HashMap<String, String>();
    boolean isGWT = true;
    try {/*from   w ww .  j a  va 2s .c o  m*/
        if (log.isDebugEnabled())
            log.debug(request.getParameterMap());
        ServletFileUpload upload = new ServletFileUpload();
        FileItemIterator iter = upload.getItemIterator(request);
        // pick up parameters first and note actual FileItem
        while (iter.hasNext()) {
            FileItemStream item = iter.next();
            String name = item.getFieldName();
            if (item.isFormField()) {
                args.put(name, Streams.asString(item.openStream()));
            } else {
                args.put("contentType", item.getContentType());
                String fileName = item.getName();
                int slash = fileName.lastIndexOf("/");
                if (slash < 0)
                    slash = fileName.lastIndexOf("\\");
                if (slash > 0)
                    fileName = fileName.substring(slash + 1);
                args.put("fileName", fileName);
                // upload requests can come from smartGWT (args) or
                // FCKEditor (request)
                String contextName = args.get("context");
                String model = args.get("model");
                String path = args.get("path");
                if (contextName == null) {
                    isGWT = false;
                    contextName = request.getParameter("context");
                    model = request.getParameter("model");
                    path = request.getParameter("path");
                    if (log.isDebugEnabled())
                        log.debug("query=" + request.getQueryString());
                } else if (log.isDebugEnabled())
                    log.debug(args);
                // the following code stores the file based on your parameters
                /*               ProjectContext context = ContextService.get().getContext(
                                     contextName);
                               ProjectState state = (ProjectState) request.getSession()
                                     .getAttribute(contextName);
                               InputStream in = null;
                               try {
                                  in = item.openStream();
                                  state.getFileManager().storeFile(
                context.getModel(model), path + fileName, in);
                               } catch (Exception e) {
                                  e.printStackTrace();
                                  log.error("Fail to upload " + fileName + " to " + path);
                               } finally {
                                  if (in != null)
                                     try {
                in.close();
                                     } catch (Exception e) {
                                     }
                               }
                */
            }
        }
        // TODO: need to handle conversion options and error reporting
        response.setContentType("text/html");
        response.setHeader("Pragma", "No-cache");
        response.setDateHeader("Expires", 0);
        response.setHeader("Cache-Control", "no-cache");
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<body>");
        if (isGWT) {
            out.println("<script type=\"text/javascript\">");
            out.println("if (parent.uploadComplete) parent.uploadComplete('" + args.get("fileName") + "');");
            out.println("</script>");
        } else
            out.println(getEditorResponse());
        out.println("</body>");
        out.println("</html>");
        out.flush();
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}

From source file:com.nkapps.billing.controllers.PaymentController.java

@RequestMapping(value = "/key-payment-list", method = RequestMethod.POST)
public @ResponseBody HashMap<String, Object> keyPaymentList(HttpServletRequest request,
        HttpServletResponse response) {//from   ww  w . j  av a  2 s  . c  om
    HashMap<String, Object> resMap = new LinkedHashMap<String, Object>();

    try {

        Map<String, String[]> map = request.getParameterMap();
        HashMap<String, String> parameters = new HashMap<>();

        for (String key : map.keySet()) {
            String[] mapValue = map.get(key);
            parameters.put(key, mapValue[0]);
        }

        resMap.put("success", true);
        resMap.put("draw", request.getParameter("draw"));

        if (parameters.get("paymentId") != null) {
            resMap.put("data", paymentService.getKeyPaymentList(parameters));
        } else {
            resMap.put("data", new HashMap<>());
        }

    } catch (Exception e) {
        logger.error(e.getMessage());
        resMap.put("success", false);
        resMap.put("reason", e.getMessage());
    }

    return resMap;
}

From source file:com.zaizi.alfresco.crowd.sso.filter.CrowdSSOAuthenticationFilter.java

/**
 * <p>Try to authenticate the user with Crowd if the username and password are contained in the request</p>
 * /*from   ww w. j  ava 2 s.  c  o  m*/
 * @param request The request
 * @param response The response
 */
private void performCrowdAuthentication(HttpServletRequest request, HttpServletResponse response) {
    @SuppressWarnings("rawtypes")
    Map parameters = request.getParameterMap();
    if ((parameters.containsKey(LOGIN_FORM_USER_NAME)) && (parameters.containsKey(LOGIN_FORM_USER_PASSWORD))) {
        String userName = request.getParameter(LOGIN_FORM_USER_NAME);
        String password = request.getParameter(LOGIN_FORM_USER_PASSWORD);
        try {
            this.crowdHttpAuthenticator.authenticate(request, response, userName, password);
        } catch (Exception e) {
            this.logger.warn("Attempted to authenticate with crowd to get a crowd token: " + e.getMessage());
        }
    }
}

From source file:gov.nih.nci.cabig.caaers.web.ae.ListAdverseEventsController.java

@Override
@SuppressWarnings("unchecked")
protected boolean isFormSubmission(HttpServletRequest request) {
    Set<String> paramNames = request.getParameterMap().keySet();
    boolean hasParticipant = paramNames.contains("participant") || paramNames.contains("mrn")
            || paramNames.contains("assignment");
    boolean hasStudy = paramNames.contains("study") || paramNames.contains("nciIdentifier")
            || paramNames.contains("assignment");
    boolean hasStudySubjectGridId = paramNames.contains("studySubjectGridId");
    return (hasParticipant && hasStudy) || hasStudySubjectGridId;
}

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

@SuppressWarnings("unchecked")
@RequestMapping/*  ww  w.j av  a  2  s.c  om*/
public String lista(HttpServletRequest request, HttpServletResponse response, Cancelacion cancelacion,
        Errors errors, Model modelo) throws ParseException {
    log.debug("Mostrando lista de cancelaciones");
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    Map<String, Object> params = this.convierteParams(request.getParameterMap());
    Long almacenId = (Long) request.getSession().getAttribute("almacenId");
    params.put("almacen", almacenId);

    if (params.containsKey("fechaIniciado")) {
        log.debug("FechaIniciado: {}", params.get("fechaIniciado"));
        params.put("fechaIniciado", sdf.parse((String) params.get("fechaIniciado")));
    }

    if (params.containsKey("fechaTerminado")) {
        params.put("fechaTerminado", sdf.parse((String) params.get("fechaTerminado")));
    }

    if (params.containsKey("tipo") && StringUtils.isNotBlank((String) params.get("tipo"))) {
        params.put("reporte", true);
        params = cancelacionDao.lista(params);
        try {
            generaReporte((String) params.get("tipo"), (List<Cancelacion>) params.get("cancelaciones"),
                    response, "cancelaciones", Constantes.ALM, almacenId);
            return null;
        } catch (ReporteException e) {
            log.error("No se pudo generar el reporte", e);
            params.remove("reporte");
            errors.reject("error.generar.reporte");
        }
    }

    if (params.containsKey("correo") && StringUtils.isNotBlank((String) params.get("correo"))) {
        params.put("reporte", true);
        params = cancelacionDao.lista(params);

        params.remove("reporte");
        try {
            enviaCorreo((String) params.get("correo"), (List<Cancelacion>) params.get("cancelaciones"), request,
                    "cancelaciones", Constantes.ALM, almacenId);
            modelo.addAttribute("message", "lista.enviada.message");
            modelo.addAttribute("messageAttrs",
                    new String[] {
                            messageSource.getMessage("cancelacion.lista.label", null, request.getLocale()),
                            ambiente.obtieneUsuario().getUsername() });
        } catch (ReporteException e) {
            log.error("No se pudo enviar el reporte por correo", e);
        }
    }
    params = cancelacionDao.lista(params);
    modelo.addAttribute("cancelaciones", params.get("cancelaciones"));

    Long pagina = 1l;
    if (params.containsKey("pagina")) {
        pagina = (Long) params.get("pagina");
    }
    this.pagina(params, modelo, "cancelaciones", pagina);

    return "inventario/cancelacion/lista";
}