Example usage for javax.servlet.http HttpServletRequest getParameterNames

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

Introduction

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

Prototype

public Enumeration<String> getParameterNames();

Source Link

Document

Returns an Enumeration of String objects containing the names of the parameters contained in this request.

Usage

From source file:es.pode.buscador.presentacion.basico.enviarMail.ResultadoEnvioBuscar.java

public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping,
        org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request,
        javax.servlet.http.HttpServletResponse response) throws java.lang.Exception {
    final ResultadoEnvioBuscarFormImpl specificForm = (ResultadoEnvioBuscarFormImpl) form;

    org.apache.struts.action.ActionForward forward = null;

    try {//from   w  w  w .j a va2s.  com
        forward = mapping.findForward("buscar");
    } catch (java.lang.Exception exception) {
        // we populate the current form with only the request parameters
        Object currentForm = request.getSession().getAttribute("form");
        // if we can't get the 'form' from the session, try from the request
        if (currentForm == null) {
            currentForm = request.getAttribute("form");
        }
        if (currentForm != null) {
            final java.util.Map parameters = new java.util.HashMap();
            for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();) {
                final String name = String.valueOf(names.nextElement());
                parameters.put(name, request.getParameter(name));
            }
            try {
                org.apache.commons.beanutils.BeanUtils.populate(currentForm, parameters);
            } catch (java.lang.Exception populateException) {
                // ignore if we have an exception here (we just don't populate).
            }
        }
        throw exception;
    }
    request.getSession().setAttribute("form", form);

    return forward;
}

From source file:es.pode.administracion.presentacion.adminusuarios.activarUsuario.ActivarUsuarioFormImpl.java

/**
 * Override to provide population of current form with request parameters when validation fails.
 *
 * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
 *//*www. j a  v a 2 s. com*/
public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping,
        javax.servlet.http.HttpServletRequest request) {
    final org.apache.struts.action.ActionErrors errors = super.validate(mapping, request);
    if (errors != null && !errors.isEmpty()) {
        // we populate the current form with only the request parameters
        Object currentForm = request.getSession().getAttribute("form");
        // if we can't get the 'form' from the session, try from the request
        if (currentForm == null) {
            currentForm = request.getAttribute("form");
        }
        if (currentForm != null) {
            final java.util.Map parameters = new java.util.HashMap();
            for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();) {
                final String name = String.valueOf(names.nextElement());
                parameters.put(name, request.getParameter(name));
            }
            try {
                org.apache.commons.beanutils.BeanUtils.populate(currentForm, parameters);
            } catch (java.lang.Exception populateException) {
                // ignore if we have an exception here (we just don't populate).
            }
        }
    }
    return errors;
}

From source file:es.pode.buscador.presentacion.avanzado.eliminarOdes.ConfirmacionCancelar.java

public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping,
        org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request,
        javax.servlet.http.HttpServletResponse response) throws java.lang.Exception {
    final ConfirmacionCancelarFormImpl specificForm = (ConfirmacionCancelarFormImpl) form;

    org.apache.struts.action.ActionForward forward = null;

    try {/*  ww  w  .ja  v  a2  s .  c  o  m*/
        forward = mapping.findForward("cancelar");
    } catch (java.lang.Exception exception) {
        // we populate the current form with only the request parameters
        Object currentForm = request.getSession().getAttribute("form");
        // if we can't get the 'form' from the session, try from the request
        if (currentForm == null) {
            currentForm = request.getAttribute("form");
        }
        if (currentForm != null) {
            final java.util.Map parameters = new java.util.HashMap();
            for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();) {
                final String name = String.valueOf(names.nextElement());
                parameters.put(name, request.getParameter(name));
            }
            try {
                org.apache.commons.beanutils.BeanUtils.populate(currentForm, parameters);
            } catch (java.lang.Exception populateException) {
                // ignore if we have an exception here (we just don't populate).
            }
        }
        throw exception;
    }
    request.getSession().setAttribute("form", form);

    return forward;
}

From source file:es.pode.buscador.presentacion.basico.enviarMail.ResultadoEnvioAceptar.java

public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping,
        org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request,
        javax.servlet.http.HttpServletResponse response) throws java.lang.Exception {
    final ResultadoEnvioAceptarFormImpl specificForm = (ResultadoEnvioAceptarFormImpl) form;

    org.apache.struts.action.ActionForward forward = null;

    try {/*from  ww w  .ja  va  2s .  c om*/
        forward = mapping.findForward("aceptar");
    } catch (java.lang.Exception exception) {
        // we populate the current form with only the request parameters
        Object currentForm = request.getSession().getAttribute("form");
        // if we can't get the 'form' from the session, try from the request
        if (currentForm == null) {
            currentForm = request.getAttribute("form");
        }
        if (currentForm != null) {
            final java.util.Map parameters = new java.util.HashMap();
            for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();) {
                final String name = String.valueOf(names.nextElement());
                parameters.put(name, request.getParameter(name));
            }
            try {
                org.apache.commons.beanutils.BeanUtils.populate(currentForm, parameters);
            } catch (java.lang.Exception populateException) {
                // ignore if we have an exception here (we just don't populate).
            }
        }
        throw exception;
    }
    request.getSession().setAttribute("form", form);

    return forward;
}

From source file:es.pode.empaquetador.presentacion.archivos.gestor.GestorArchivosGuardar.java

public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping,
        org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request,
        javax.servlet.http.HttpServletResponse response) throws java.lang.Exception {
    final GestorArchivosGuardarFormImpl specificForm = (GestorArchivosGuardarFormImpl) form;

    org.apache.struts.action.ActionForward forward = null;

    try {/*from w  w w  . j  a  v  a  2s .  c o m*/
        forward = mapping.findForward("guardar");
    } catch (java.lang.Exception exception) {
        // we populate the current form with only the request parameters
        Object currentForm = request.getSession().getAttribute("form");
        // if we can't get the 'form' from the session, try from the request
        if (currentForm == null) {
            currentForm = request.getAttribute("form");
        }
        if (currentForm != null) {
            final java.util.Map parameters = new java.util.HashMap();
            for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();) {
                final String name = String.valueOf(names.nextElement());
                parameters.put(name, request.getParameter(name));
            }
            try {
                org.apache.commons.beanutils.BeanUtils.populate(currentForm, parameters);
            } catch (java.lang.Exception populateException) {
                // ignore if we have an exception here (we just don't populate).
            }
        }
        throw exception;
    }
    request.getSession().setAttribute("form", form);

    return forward;
}

From source file:es.pode.empaquetador.presentacion.avanzado.recursos.gestor.GestorRecursosGuardar.java

public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping,
        org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request,
        javax.servlet.http.HttpServletResponse response) throws java.lang.Exception {
    final GestorRecursosGuardarFormImpl specificForm = (GestorRecursosGuardarFormImpl) form;

    org.apache.struts.action.ActionForward forward = null;

    try {//from  w  w  w.j  a  va  2  s .co m
        forward = mapping.findForward("guardar");
    } catch (java.lang.Exception exception) {
        // we populate the current form with only the request parameters
        Object currentForm = request.getSession().getAttribute("form");
        // if we can't get the 'form' from the session, try from the request
        if (currentForm == null) {
            currentForm = request.getAttribute("form");
        }
        if (currentForm != null) {
            final java.util.Map parameters = new java.util.HashMap();
            for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();) {
                final String name = String.valueOf(names.nextElement());
                parameters.put(name, request.getParameter(name));
            }
            try {
                org.apache.commons.beanutils.BeanUtils.populate(currentForm, parameters);
            } catch (java.lang.Exception populateException) {
                // ignore if we have an exception here (we just don't populate).
            }
        }
        throw exception;
    }
    request.getSession().setAttribute("form", form);

    return forward;
}

From source file:es.pode.tagging.presentacion.adminTag.listarTag.ListadoTagsModificar.java

public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping,
        org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request,
        javax.servlet.http.HttpServletResponse response) throws java.lang.Exception {
    final ListadoTagsModificarFormImpl specificForm = (ListadoTagsModificarFormImpl) form;

    org.apache.struts.action.ActionForward forward = null;

    try {//w w  w  .  j ava2 s  .  c o m
        forward = mapping.findForward("modificar");
    } catch (java.lang.Exception exception) {
        // we populate the current form with only the request parameters
        Object currentForm = request.getSession().getAttribute("form");
        // if we can't get the 'form' from the session, try from the request
        if (currentForm == null) {
            currentForm = request.getAttribute("form");
        }
        if (currentForm != null) {
            final java.util.Map parameters = new java.util.HashMap();
            for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();) {
                final String name = String.valueOf(names.nextElement());
                parameters.put(name, request.getParameter(name));
            }
            try {
                org.apache.commons.beanutils.BeanUtils.populate(currentForm, parameters);
            } catch (java.lang.Exception populateException) {
                // ignore if we have an exception here (we just don't populate).
            }
        }
        throw exception;
    }
    request.getSession().setAttribute("form", form);

    return forward;
}

From source file:es.pode.administracion.presentacion.informes.crearInforme.ListadoFechasCancelar.java

public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping,
        org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request,
        javax.servlet.http.HttpServletResponse response) throws java.lang.Exception {
    final ListadoFechasCancelarFormImpl specificForm = (ListadoFechasCancelarFormImpl) form;

    org.apache.struts.action.ActionForward forward = null;

    try {//from w  w w.j  a va 2s .  c o m
        forward = mapping.findForward("cancelar");
    } catch (java.lang.Exception exception) {
        // we populate the current form with only the request parameters
        Object currentForm = request.getSession().getAttribute("form");
        // if we can't get the 'form' from the session, try from the request
        if (currentForm == null) {
            currentForm = request.getAttribute("form");
        }
        if (currentForm != null) {
            final java.util.Map parameters = new java.util.HashMap();
            for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();) {
                final String name = String.valueOf(names.nextElement());
                parameters.put(name, request.getParameter(name));
            }
            try {
                org.apache.commons.beanutils.BeanUtils.populate(currentForm, parameters);
            } catch (java.lang.Exception populateException) {
                // ignore if we have an exception here (we just don't populate).
            }
        }
        throw exception;
    }
    request.getSession().setAttribute("form", form);

    return forward;
}

From source file:es.pode.administracion.presentacion.planificador.descripcionTarea.MostrarCargaODEsVolver.java

public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping,
        org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request,
        javax.servlet.http.HttpServletResponse response) throws java.lang.Exception {
    final MostrarCargaODEsVolverFormImpl specificForm = (MostrarCargaODEsVolverFormImpl) form;

    org.apache.struts.action.ActionForward forward = null;

    try {/*from   w w w.  j ava  2s .  c o m*/
        forward = mapping.findForward("volver");
    } catch (java.lang.Exception exception) {
        // we populate the current form with only the request parameters
        Object currentForm = request.getSession().getAttribute("form");
        // if we can't get the 'form' from the session, try from the request
        if (currentForm == null) {
            currentForm = request.getAttribute("form");
        }
        if (currentForm != null) {
            final java.util.Map parameters = new java.util.HashMap();
            for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();) {
                final String name = String.valueOf(names.nextElement());
                parameters.put(name, request.getParameter(name));
            }
            try {
                org.apache.commons.beanutils.BeanUtils.populate(currentForm, parameters);
            } catch (java.lang.Exception populateException) {
                // ignore if we have an exception here (we just don't populate).
            }
        }
        throw exception;
    }
    request.getSession().setAttribute("form", form);

    return forward;
}

From source file:com.autentia.tnt.servlet.ReportServlet.java

private Map getParametersAsMapAndSubReport(HttpServletRequest request, String reportCategory) throws Exception {
    JasperReport subReport;//from   ww w .ja  v a2  s.c  o  m
    Map args = new HashMap();
    Enumeration e = request.getParameterNames();
    while (e.hasMoreElements()) {
        String arg = (String) e.nextElement();
        final String value = request.getParameter(arg);
        Object obj = null;
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date value_date = sdf.parse(value);
            java.sql.Timestamp ts = new Timestamp(value_date.getTime());

            obj = ts;
        } catch (Exception ex) {
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                Date value_date = sdf.parse(value);
                obj = value_date;
            } catch (Exception ex2) {
                try {
                    Integer value_int = Integer.parseInt(value);
                    obj = value_int;
                } catch (Exception ex3) {
                    if ("true".equals(value) || "false".equals(value)) {
                        obj = Boolean.parseBoolean(value);
                    } else {
                        obj = value;
                    }
                }
            }
        }

        if (arg.startsWith("SUBREPORT")) {
            if (reportCategory.equals("personal/")) {
                String path = ConfigurationUtil.getDefault().getReportPath();
                String target = path + ReportUtil.SUBREPORT_PREFIX + obj;
                if (null == Thread.currentThread().getContextClassLoader()
                        .getResource(target + ReportUtil.REPORT_DEFINITION_SUFFIX)) {
                    try {
                        JasperCompileManager.compileReportToFile(target + ReportUtil.REPORT_DEFINITION_SUFFIX);
                    } catch (JRException jre) {
                        log.error("error compiling subreport", jre);
                        throw jre;
                    }
                }
                subReport = (JasperReport) JRLoader.loadObject(target + ReportUtil.REPORT_SUFFIX);
                obj = target + ReportUtil.REPORT_SUFFIX;
            } else {
                String destino = ReportUtil.REPORT_PREFIX + reportCategory + ReportUtil.SUBREPORT_PREFIX + obj
                        + ReportUtil.REPORT_SUFFIX;
                if (null == getResourceAsURL(destino)) {
                    JasperCompileManager
                            .compileReportToFile(getResourceAsString(ReportUtil.REPORT_PREFIX + reportCategory
                                    + ReportUtil.SUBREPORT_PREFIX + obj + ReportUtil.REPORT_DEFINITION_SUFFIX));
                }

                subReport = (JasperReport) JRLoader.loadObject(getResourceAsURL(destino));
                obj = destino;
            }
        }
        args.put(arg, obj);
    }

    return args;
}