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.activos.web.TipoActivoController.java

@RequestMapping(value = "/crea", method = RequestMethod.POST)
public String crea(HttpServletRequest request, HttpServletResponse response, @Valid TipoActivo tipoActivo,
        BindingResult bindingResult, Errors errors, Model modelo, RedirectAttributes redirectAttributes) {
    for (String nombre : request.getParameterMap().keySet()) {
        log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre));
    }// www .ja  v  a2 s  .c o  m
    if (bindingResult.hasErrors()) {
        log.debug("Hubo algun error en la forma, regresando");
        return "activoFijo/tipoActivo/nuevo";
    }

    try {
        Usuario usuario = ambiente.obtieneUsuario();
        tipoActivo = tipoActivoDao.crea(tipoActivo, usuario);
    } catch (ConstraintViolationException e) {
        log.error("No se pudo crear al tipoActivo", e);
        errors.rejectValue("nombre", "campo.duplicado.message", new String[] { "nombre" }, null);
        return "activoFijo/tipoActivo/nuevo";
    }

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

    return "redirect:/activoFijo/tipoActivo/ver/" + tipoActivo.getId();
}

From source file:nl.npcf.eav.web.EAVController.java

@SuppressWarnings("unchecked")
private Map<EAVStore.Path, String> getValues(HttpServletRequest request) throws EAVPathException {
    Map<EAVStore.Path, String> valueMap = new TreeMap<EAVStore.Path, String>();
    Map<String, String[]> parameterMap = request.getParameterMap();
    for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
        if (DELETE_PARAMETER.equals(entry.getKey())) {
            continue;
        }/*from ww  w.  j  a v  a  2s.  c om*/
        valueMap.put(eavStore.getSchema().createPath(entry.getKey(), true), entry.getValue()[0].trim());
    }
    return valueMap;
}

From source file:nl.tue.gale.ae.LoginServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    if ("post".equals(req.getParameter("http"))) {
        doPost(req, resp);/* w w  w .ja  va  2 s .c om*/
        return;
    }
    LoginManager login = (LoginManager) getApplicationContext().getBean("loginManager");
    @SuppressWarnings("unchecked")
    Map<String, String[]> parameterMap = (Map<String, String[]>) req.getParameterMap();
    String loginPage = serializeXML(login.getLoginPage(req.getParameter("method"), parameterMap));
    sendToClient(resp, new ByteArrayInputStream(loginPage.getBytes("UTF-8")), "text/html", "UTF-8");
}

From source file:org.apache.atlas.web.rest.TypesREST.java

/**
 * Populate a SearchFilter on the basis of the Query Parameters
 * @return//  w  ww .j a  v  a 2  s.c  om
 */
private SearchFilter getSearchFilter(HttpServletRequest httpServletRequest) {
    SearchFilter ret = new SearchFilter();
    Set<String> keySet = httpServletRequest.getParameterMap().keySet();
    for (String key : keySet) {
        ret.setParam(String.valueOf(key), String.valueOf(httpServletRequest.getParameter(key)));
    }

    return ret;
}

From source file:co.pugo.convert.ConvertServlet.java

@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    // parse parameters
    Parameters parameters = new Parameters(request.getParameterMap());
    if (!hasRequiredParameters(parameters, response))
        return;//from   w  ww .  j  a v a 2 s  .  c  o m

    // read config file
    Configuration configuration = new Configuration(getConfigFile(parameters.getMode()));

    // set response properties
    setResponseProperties(response, configuration.getMimeType(), parameters.getFname());

    // get URLConnection
    URLConnection urlConnection = getSourceUrlConnection(parameters.getSource(), parameters.getToken());

    // convert html source to xhtml
    InputStream html = urlConnection.getInputStream();
    ByteArrayOutputStream xhtml = new ByteArrayOutputStream();
    tidyHtml(html, xhtml);

    // read xhtml to a String
    String content = IOUtils.toString(new ByteArrayInputStream(xhtml.toByteArray()));

    // close streams
    IOUtils.closeQuietly(html);
    IOUtils.closeQuietly(xhtml);

    // process images
    if (configuration.isProcessImagesSet()) {
        Set<String> imageLinks = extractImageLinks(content);
        if (imageLinks != null)
            content = replaceImgSrcWithBase64(content, downloadImageData(imageLinks));
    }

    // xsl transformation
    setupAndRunXSLTransformation(response, configuration, content, parameters.getXslParameters());
}

From source file:com.jwebmp.plugins.datatable.DataTablesServlet.java

@Override
@SuppressWarnings("unchecked")
public void perform() {
    HttpServletRequest request = GuiceContext.get(GuicedServletKeys.getHttpServletRequestKey());
    StringBuilder output = new StringBuilder();
    Set<Class<? extends DataTableDataFetchEvent>> allEvents = new HashSet(GuiceContext.instance()
            .getScanResult().getSubclasses(DataTableDataFetchEvent.class.getCanonicalName()).loadClasses());
    Map<String, String[]> params = request.getParameterMap();
    String className = params.get("c")[0];
    allEvents.removeIf(a -> !a.getCanonicalName().equals(className.replace(CHAR_UNDERSCORE, CHAR_DOT)));
    if (allEvents.isEmpty()) {
        writeOutput(output, HTML_HEADER_JAVASCRIPT, UTF8_CHARSET);
        DataTablesServlet.log.fine("DataTablesServlet could not find any specified data search class");
    } else {/*from   w w  w . j a va2 s . c om*/
        DataTableSearchRequest searchRequest = new DataTableSearchRequest();
        searchRequest.fromRequestMap(params);
        try {
            Class<? extends DataTableDataFetchEvent> event = allEvents.iterator().next();
            DataTableDataFetchEvent dtd = GuiceContext.get(event);
            DataTableData d = dtd.returnData(searchRequest);
            output.append(d.toString());
            writeOutput(output, HTML_HEADER_JSON, UTF8_CHARSET);
        } catch (Exception e) {
            output.append(ExceptionUtils.getStackTrace(e));
            writeOutput(output, HTML_HEADER_JAVASCRIPT, UTF8_CHARSET);
            DataTablesServlet.log.log(Level.SEVERE, "Unable to execute datatables ajax data fetch", e);
        }
    }
}

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

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

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

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

    return "redirect:" + Constantes.PEDIDO_COLPORTOR_ITEM_PATH_VER + "/" + pedidoColportorItem.getId();
}

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

@RequestMapping(value = "/crea", method = RequestMethod.POST)
public String graba(HttpServletRequest request, HttpServletResponse response, @Valid Colegio colegio,
        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  av  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.COLEGIO_PATH_NUEVO;
    }

    Boolean isNew = colegio.getId() == null;

    try {
        //La organizacion la asignamos aunque esten modificando el registro
        //porque considero que es mas vulnerable si tomo organizacion.id de los parametros del jsp
        Usuario usuario = ambiente.obtieneUsuario();
        colegio.setOrganizacion(usuario.getEmpresa().getOrganizacion());

        colegioManager.crea(colegio);

    } catch (Exception e) {
        log.error("No se pudo crear al colegio", e);
        errors.rejectValue("nombre", "colegio.errors.creado", e.toString());
        return Constantes.COLEGIO_PATH_NUEVO;
    }

    if (isNew)
        redirectAttributes.addFlashAttribute("message", "colegio.creado.message");
    else
        redirectAttributes.addFlashAttribute("message", "colegio.actualizado.message");
    redirectAttributes.addFlashAttribute("messageAttrs", new String[] { colegio.getNombre() });

    return "redirect:" + Constantes.COLEGIO_PATH;
}

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

protected void doDirectPay(final HttpServletRequest request, final HttpServletResponse response)
        throws IOException {
    final Map<String, String[]> requestParamMap = request.getParameterMap();
    if (requestParamMap == null) {
        return;// www.j a  v a2 s .c om
    }
    final Map<String, String> requestType = createRequestTypeMap(requestParamMap);
    final Map<String, String> clearParams = removeUselessValue(requestParamMap);
    this.setCSRFToken(clearParams, request);

    final String sign = mockService.getSign(clearParams);
    final boolean signIsValid = sign.equals(clearParams.get("sign"));
    if (signIsValid) {
        final String service = request.getParameter("service");
        if (service != null) {
            XSSFilterUtil.filter(service);
            if ("create_direct_pay_by_user".equals(service)) {
                handleDirectPayRequest(clearParams, response, signIsValid, requestType);
            }
        }
    }
}

From source file:mx.edu.um.mateo.colportor.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));
    }//w ww .j a  v a2 s.com
    if (bindingResult.hasErrors()) {
        log.debug("Hubo algun error en la forma, regresando");
        for (ObjectError error : bindingResult.getAllErrors()) {
            log.debug("Error: {}", error);
        }
        modelo.addAttribute(Constantes.CONTAINSKEY_UNIONES,
                unionDao.lista(null).get(Constantes.CONTAINSKEY_UNIONES));
        return Constantes.PATH_ASOCIACION_NUEVA;
    }
    try {
        Usuario usuario = null;
        if (ambiente.obtieneUsuario() != null) {
            usuario = ambiente.obtieneUsuario();
        }
        asociacion = asociacionDao.crea(asociacion, usuario);
        ambiente.actualizaSesion(request.getSession(), usuario);
    } catch (ConstraintViolationException e) {
        log.error("No se pudo crear al Asociacion", e);
        errors.rejectValue("nombre", "campo.duplicado.message", new String[] { "nombre" }, null);
        modelo.addAttribute(Constantes.CONTAINSKEY_UNIONES,
                unionDao.lista(null).get(Constantes.CONTAINSKEY_UNIONES));
        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();
}