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:org.openmrs.module.hospitalcore.web.controller.form.ShowFormController.java
@SuppressWarnings("rawtypes") private Map<String, String> buildParameterList(HttpServletRequest request) { Map<String, String> parameters = new HashMap<String, String>(); for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) { String parameterName = (String) e.nextElement(); if (!parameterName.equalsIgnoreCase("id")) if (!parameterName.equalsIgnoreCase("mode")) if (!parameterName.equalsIgnoreCase("encounterId")) if (!parameterName.equalsIgnoreCase("redirect")) parameters.put(parameterName, request.getParameter(parameterName)); }/*from w w w. j a va 2 s.com*/ return parameters; }
From source file:org.impalaframework.extension.mvc.util.RequestModelHelperTest.java
@SuppressWarnings("unchecked") public void testSetParameters() { HttpServletRequest request = createMock(HttpServletRequest.class); HashMap model = new HashMap(); model.put("p2", "2a"); model.put("p3", null); expect(request.getParameterNames()) .andReturn(Collections.enumeration(Arrays.asList("p1", "p2", "p3", "p4"))); expect(request.getParameter("p1")).andReturn("1"); //expect(request.getParameter("p2")).andReturn("2"); //expect(request.getParameter("p3")).andReturn("3"); expect(request.getParameter("p4")).andReturn(""); replay(request);//from w w w . j av a 2 s. c om RequestModelHelper.setParameters(request, model); assertEquals(4, model.size()); assertEquals("1", model.get("p1")); assertEquals("2a", model.get("p2")); assertEquals(null, model.get("p3")); assertEquals("", model.get("p4")); verify(request); }
From source file:de.thischwa.pmcms.server.ContentSaverServlet.java
@Override protected void doRequest(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Map<String, String> params = new HashMap<String, String>(); Enumeration<?> paramNames = req.getParameterNames(); while (paramNames.hasMoreElements()) { Object paramName = paramNames.nextElement(); String name = Utils.stripNonValidXMLCharacters(paramName.toString()); String value = Utils.stripNonValidXMLCharacters(req.getParameter(name)); params.put(name, value);/* w w w . j a v a2s .c om*/ } APoormansObject<?> po = ContextUtil.updatepo(params); logger.info("Saved pojo: " + po.toString()); try { if (InstanceUtil.isSiteResource(po)) velocityRenderer.render(resp.getWriter(), (ASiteResource) po); else velocityRenderer.render(resp.getWriter(), (IRenderable) po, ViewMode.PREVIEW); } catch (RenderingException e) { throw new IOExceptionWithCause(e); } resp.setHeader("Cache-Control", "no-cache"); }
From source file:com.minlia.cloud.framework.common.web.controller.AbstractReadOnlyController.java
protected final List<T> findAllInternal(final HttpServletRequest request, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { if (request.getParameterNames().hasMoreElements()) { throw new MyResourceNotFoundException(); }//from w w w .j a va 2 s .com eventPublisher.publishEvent(new MultipleResourcesRetrievedEvent<T>(clazz, uriBuilder, response)); return getService().findAll(); }
From source file:org.openmrs.module.radiology.web.controller.form.ShowFormController.java
@SuppressWarnings("rawtypes") private Map<String, String> buildParameterList(HttpServletRequest request) { Map<String, String> parameters = new HashMap<String, String>(); for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) { String parameterName = (String) e.nextElement(); if (!parameterName.equalsIgnoreCase("id")) if (!parameterName.equalsIgnoreCase("mode")) if (!parameterName.equalsIgnoreCase("encounterId")) if (!parameterName.equalsIgnoreCase("redirectUrl")) parameters.put(parameterName, request.getParameter(parameterName)); }//from w w w .j av a 2 s .c om return parameters; }
From source file:com.shopzilla.publisher.web.HomeController.java
@PerfTimed @RequestMapping(value = "filter", method = RequestMethod.GET) public String filter(HttpServletRequest request, Model uiModel) { StringBuilder query = new StringBuilder(); Enumeration requestEnum = request.getParameterNames(); while (requestEnum.hasMoreElements()) { String key = (String) requestEnum.nextElement(); for (String str : request.getParameterValues(key)) { query.append(key);/*from w w w .jav a2 s . co m*/ query.append(":"); query.append(str); query.append(";"); } } query.deleteCharAt(query.length() - 1); String queryStr = query.toString(); this.offers.clear(); this.products.clear(); List<Category> categoryList = categoryProviderService.fetchCategories(); for (Category category : categoryList) { CatalogResponse response = categorySearchService.attributeSearch(category.getId(), 10, queryStr); this.offers.addAll(response.getOffers()); this.products.addAll(response.getProducts()); } uiModel.addAttribute("offers", this.offers); uiModel.addAttribute("products", this.products); uiModel.addAttribute("attributes", this.attributes); return "index"; }
From source file:org.lareferencia.xoai.controller.LROAIDataProvider.java
private Map<String, List<String>> buildParametersMap(HttpServletRequest request) { Map<String, List<String>> map = new HashMap<String, List<String>>(); Enumeration names = request.getParameterNames(); while (names.hasMoreElements()) { String name = (String) names.nextElement(); String[] values = request.getParameterValues(name); map.put(name, asList(values));//from ww w. j a v a2 s .c o m } return map; }
From source file:com.xpn.xwiki.web.ActionFilter.java
/** * {@inheritDoc}//from www .ja va2 s . c o m * * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain) */ @SuppressWarnings("unchecked") public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { // Only HTTP requests can be dispatched. if (request instanceof HttpServletRequest && !Boolean.valueOf((String) request.getAttribute(ATTRIBUTE_ACTION_DISPATCHED))) { HttpServletRequest hrequest = (HttpServletRequest) request; Enumeration<String> parameterNames = hrequest.getParameterNames(); while (parameterNames.hasMoreElements()) { String parameter = parameterNames.nextElement(); if (parameter.startsWith(ACTION_PREFIX)) { String targetURL = getTargetURL(hrequest, parameter); RequestDispatcher dispatcher = hrequest.getRequestDispatcher(targetURL); if (dispatcher != null) { LOG.debug("Forwarding request to " + targetURL); request.setAttribute(ATTRIBUTE_ACTION_DISPATCHED, "true"); dispatcher.forward(hrequest, response); // Allow multiple calls to this filter as long as they are not nested. request.removeAttribute(ATTRIBUTE_ACTION_DISPATCHED); // If the request was forwarder to another path, don't continue the normal processing chain. return; } } } } // Let the request pass through unchanged. chain.doFilter(request, response); }
From source file:com.stimulus.struts.BaseBean.java
protected final SubmitButton getSubmitButton() { HttpServletRequest request = ActionContext.getActionContext().getRequest(); Enumeration enumo = request.getParameterNames(); SubmitButton button = new SubmitButton(); String parameterName = null;/*from w w w. j a v a 2s. c o m*/ while (enumo.hasMoreElements()) { parameterName = (String) enumo.nextElement(); if (parameterName.startsWith("submit.")) { String temp = parameterName.substring(parameterName.indexOf("submit.") + 7, parameterName.length()); if (temp.indexOf('.') < 1) button.action = temp; else { button.action = temp.substring(0, temp.indexOf('.')); button.value = temp.substring(button.action.length() + 1, temp.length()); } } } return button; }