List of usage examples for javax.servlet.http HttpServletRequest getParameterNames
public Enumeration<String> getParameterNames();
Enumeration
of String
objects containing the names of the parameters contained in this request. From source file:es.pode.catalogadorWeb.presentacion.catalogadorAvanzado.CategoriasFormModificarGeneral.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 CategoriasFormModificarGeneralFormImpl specificForm = (CategoriasFormModificarGeneralFormImpl) form; org.apache.struts.action.ActionForward forward = null; try {/* w w w . j a va2 s . c om*/ forward = mapping.findForward("modificar.general"); } 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.catalogadorWeb.presentacion.catalogadorAvanzado.CategoriasFormModificarTecnica.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 CategoriasFormModificarTecnicaFormImpl specificForm = (CategoriasFormModificarTecnicaFormImpl) form; org.apache.struts.action.ActionForward forward = null; try {//from w w w .ja v a 2 s . com forward = mapping.findForward("modificar.tecnica"); } 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.catalogadorWeb.presentacion.categoriasAvanzado.usoeducativo.UsosEducativosFormDetalleUsoEdu.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 UsosEducativosFormDetalleUsoEduFormImpl specificForm = (UsosEducativosFormDetalleUsoEduFormImpl) form; org.apache.struts.action.ActionForward forward = null; try {/*from www . ja v a 2 s . com*/ forward = mapping.findForward("detalle.uso.edu"); } 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.catalogadorWeb.presentacion.tesauros.TesaurosFormBuscar.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 TesaurosFormBuscarFormImpl specificForm = (TesaurosFormBuscarFormImpl) form; org.apache.struts.action.ActionForward forward = null; try {//from w w w .java2 s.c o m forward = _buscarTerminos(mapping, form, request, response); } 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.modificador.presentacion.configurar.nombre.CrearModificacionBuscar.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 CrearModificacionBuscarFormImpl specificForm = (CrearModificacionBuscarFormImpl) form; org.apache.struts.action.ActionForward forward = null; try {/*www . jav a 2 s .co m*/ forward = _busqueda(mapping, form, request, response); } 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.modificador.presentacion.configurar.objetos.resultados.ResultadosBusquedaBuscar.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 ResultadosBusquedaBuscarFormImpl specificForm = (ResultadosBusquedaBuscarFormImpl) form; org.apache.struts.action.ActionForward forward = null; try {//w ww .j ava2s. c o m forward = _buscar(mapping, form, request, response); } 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.presentacion.visualizadorAdl.LmsmainDatosBorrar.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 LmsmainDatosBorrarFormImpl specificForm = (LmsmainDatosBorrarFormImpl) form; org.apache.struts.action.ActionForward forward = null; try {//w ww .j a v a 2 s .c om forward = _borrarDatosAdl(mapping, form, request, response); } 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.matthewcasperson.validation.filter.ParameterValidationFilter.java
/** * This filter implements multiple chains of validation rules. Each chain is executed against each parameter until * alll validation rules have been executed, or until one of the validation rules stops the execution of the chain. *///from ww w .j av a 2 s . c o m @Override public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { //LOGGER.log(Level.INFO, "Parameter Validation Filter processing request"); ServletRequest requestWrapper = request; try { if (parameterValidationDefinitions != null && parameterValidationDefinitions.getParameterValidationDefinitions() != null) { LOGGER.log(Level.FINE, "Parameter Validation Filter has loaded the config file"); if (requestWrapper instanceof HttpServletRequest) { //LOGGER.log(Level.INFO, "Parameter Validation Filter is filtering a HttpServletRequest"); final HttpServletRequest httpServletRequest = (HttpServletRequest) requestWrapper; /* * Loop over each param. Note that while the validation rules may well * create wrappers that return different values for the params (i.e. requestWrapper is * updated to reference a new wrapper), we use this original copy for the list of * param keys to loop over. */ final Enumeration<String> iter = httpServletRequest.getParameterNames(); paramaterNameLoop: while (iter.hasMoreElements()) { /* * Get the param name and move the enumerator along */ final String paramName = iter.nextElement(); boolean paramValidated = false; LOGGER.log(Level.FINE, "Parameter Validation Filter processing " + paramName); /* * Loop over each validation rule in the chain */ final List<ParameterValidationChain> validationChains = parameterValidationDefinitions .getParameterValidationDefinitions(); for (final ParameterValidationChain validationChain : validationChains) { checkState(validationChain != null, "A validation rule should never be null"); /* * Test this validation rule against the param name */ final boolean paramMatches = validationChain.getParamNamePattern().matcher(paramName) .find(); final boolean uriMatches = validationChain.getRequestURIPattern() .matcher(httpServletRequest.getRequestURI()).find(); final boolean paramMatchesAfterNegation = paramMatches ^ validationChain.isParamNamePatternNegated(); final boolean uriMatchesAfterNegation = uriMatches ^ validationChain.isRequestURIPatternNegated(); if (paramMatchesAfterNegation && uriMatchesAfterNegation) { LOGGER.log(Level.FINE, "Parameter Validation Filter found matching chain"); /* * Make a note that this parameter has been validated by at least one rule */ paramValidated = true; /* * Loop over each rule in the chain */ for (final ParameterValidationDefinitionImpl validationRule : validationChain .getList()) { LOGGER.log(Level.FINE, "Processing " + paramName + " with " + validationRule.getValidationRuleName()); /* * Get the object that will actually do the validation */ final ParameterValidationRule rule = validationRule.getRule(); /* * It is possible that a bad configuration will result in rule being null */ checkState(rule != null, "A validation rule should never be null. Check the class name defined in the configuration xml file."); try { /* Process the parameter */ final ServletRequest processRequest = rule.processParameter(requestWrapper, paramName); checkState(processRequest != null, "A validation rule should never return null when processing a paramemter"); /* * The validation rule is expected to return a valid request regardless of the * processing that should or should not be done. */ requestWrapper = processRequest; } catch (final ValidationFailedException ex) { /* * Log this as a warning as we are probably interested in knowing when our apps * are getting hit with invalid data. */ LOGGER.log(Level.WARNING, ex.toString()); if (parameterValidationDefinitions.getEnforcingMode()) { /* If we are enforcing, rethrow so the outer catch block can block the request */ throw ex; } else { /* Otherwise move to the next parameter name. This allows us to be notified of every param that will fail instead of just bailing with the first one that fails. */ continue paramaterNameLoop; } } } } } if (!paramValidated) { /* * This might be intentional, so log it as an INFO */ LOGGER.log(Level.INFO, "PVF-INFO-0001: " + paramName + " has not been validated."); } } } } } catch (final ValidationFailedException ex) { /* * Stop processing and return a HTTP error code if we are enforcing the rules */ if (parameterValidationDefinitions.getEnforcingMode()) { respondWithBadRequest(response); return; } } catch (final Exception ex) { /* * We probably reach this because of some invalid state due to rules returning null * or throwing unchecked exceptions during their own processing. This is logged as * severe as it is most likely a bug in the code. */ LOGGER.log(Level.SEVERE, ExceptionUtils.getFullStackTrace(ex)); /* * Don't allow apps to process raw parameters if this filter has failed and we are * enforcing the rules */ if (parameterValidationDefinitions.getEnforcingMode()) { respondWithBadRequest(response); return; } } /* * Continue to the next filter */ if (parameterValidationDefinitions.getEnforcingMode()) { /* In enforcing mode we pass the wrapper onto the next filter */ chain.doFilter(requestWrapper, response); } else { /* If enforcing mode is not enabled, we pass through the original request */ chain.doFilter(request, response); } }
From source file:es.pode.buscador.presentacion.avanzado.eliminarOdes.ConfirmacionAceptar.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 ConfirmacionAceptarFormImpl specificForm = (ConfirmacionAceptarFormImpl) form; org.apache.struts.action.ActionForward forward = null; try {//w w w.j av a 2 s . c om forward = _eliminarOdes(mapping, form, request, response); } 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.avanzado.tesauros.TesaurosConsultaNodo.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 TesaurosConsultaNodoFormImpl specificForm = (TesaurosConsultaNodoFormImpl) form; org.apache.struts.action.ActionForward forward = null; try {//from w w w . j a v a2s .c o m forward = _consultarId(mapping, form, request, response); } 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; }