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:com.tek271.reverseProxy.servlet.ProxyFilter.java
@SuppressWarnings({ "unchecked" }) private static StringEntity getEntity(HttpServletRequest request) throws IOException { if (APPLICATION_JSON.equalsIgnoreCase(request.getHeader("Content-type"))) { StringBuilder stringBuilder = new StringBuilder(); BufferedReader bufferedReader = null; InputStream inputStream = request.getInputStream(); if (inputStream != null) { bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); char[] charBuffer = new char[512]; int bytesRead = -1; while ((bytesRead = bufferedReader.read(charBuffer)) > 0) { stringBuilder.append(charBuffer, 0, bytesRead); }/*from w w w . j a v a 2 s . c om*/ if (bufferedReader != null) { bufferedReader.close(); } } else { stringBuilder.append(""); } return new StringEntity(stringBuilder.toString(), "UTF-8"); } List<NameValuePair> formparams = new ArrayList<NameValuePair>(); Enumeration<String> en = request.getParameterNames(); while (en.hasMoreElements()) { String name = en.nextElement(); String value = request.getParameter(name); formparams.add(new BasicNameValuePair(name, value)); } return new UrlEncodedFormEntity(formparams, "UTF-8"); }
From source file:com.jaeksoft.searchlib.renderer.filter.RendererFilterQueries.java
public void applyServletRequest(HttpServletRequest servletRequest) { if (servletRequest.getParameter("fqc") != null) filterQueries.clear();//from w w w . j a va2 s .c o m Enumeration<String> en = servletRequest.getParameterNames(); if (en != null) { while (en.hasMoreElements()) { String parm = en.nextElement(); if (parm.startsWith("fqa.")) addTerm(parm.substring(4), servletRequest.getParameterValues(parm)); if (parm.startsWith("fqr.")) removeTerm(parm.substring(4), servletRequest.getParameterValues(parm)); if (parm.startsWith("fq.")) setQuery(parm.substring(4), servletRequest.getParameter(parm)); } } }
From source file:com.surveypanel.web.admin.ShellAction.java
private void setValues(Form form) { HttpServletRequest request = ServletActionContext.getRequest(); HashMap<String, String> values = new HashMap<String, String>(); Map<String, Object> formValues = form.getFieldValues(); Enumeration fieldNames = request.getParameterNames(); while (fieldNames.hasMoreElements()) { String fieldName = (String) fieldNames.nextElement(); if (formValues.containsKey(fieldName)) { values.put(fieldName, request.getParameter(fieldName)); }/* w w w.j av a 2s . c o m*/ } form.setValues(values); }
From source file:org.openmrs.module.diseaseregistry.web.controller.patient.PatientTestController.java
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 (StringUtils.isNumeric(parameterName)) { parameters.put(parameterName, request.getParameter(parameterName)); }/*from w w w. j ava 2 s .co m*/ } return parameters; }
From source file:XsltDomServlet.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { Document doc = dom.createDocument("", "parameters", null); Element parameters = doc.getDocumentElement(); parameters.setAttribute("title", "XSLT DOM Servlet"); Enumeration parameterNames = request.getParameterNames(); while (parameterNames.hasMoreElements()) { String parameterName = parameterNames.nextElement().toString(); Element parameter = doc.createElement("parameter"); parameters.appendChild(parameter); parameter.setAttribute("name", parameterName); parameter.appendChild(doc.createTextNode(request.getParameter(parameterName))); }//from w w w . java 2 s. c o m DOMSource domSource = new DOMSource(doc); StreamResult streamResult = new StreamResult(response.getWriter()); try { transformer.transform(domSource, streamResult); } catch (TransformerException te) { throw new ServletException(te); } }
From source file:eionet.web.action.AbstractActionBean.java
/** * *//*from w ww.j a v a2s. c o m*/ protected void dumpRequestParameters() { HttpServletRequest request = getContext().getRequest(); Enumeration paramNames = request.getParameterNames(); // System.out.println(">>>>>>>>>> start request parameters dump"); // if (paramNames != null && paramNames.hasMoreElements()) { // do { // String paramName = paramNames.nextElement().toString(); // String[] paramValues = request.getParameterValues(paramName); // System.out.print(paramName + " = ["); // for (int i = 0; i < paramValues.length; i++) { // if (i > 0) { // System.out.print(", "); // } // System.out.print(paramValues[i]); // } // System.out.println("]"); // } while (paramNames.hasMoreElements()); // } else { // System.out.println("No request parameters found"); // } // System.out.println("<<<<<<<<<< end request parameters dump"); }
From source file:org.craftercms.search.controller.SearchRestController.java
protected Map<String, String> getAdditionalFields(HttpServletRequest request) { String[] ignoredParams = { REQUEST_PARAM_SITE, REQUEST_PARAM_ID, REQUEST_PARAM_DOCUMENT }; Map<String, String> additionalFields = new HashMap<String, String>(); for (Enumeration i = request.getParameterNames(); i.hasMoreElements();) { String paramName = (String) i.nextElement(); if (!ArrayUtils.contains(ignoredParams, paramName)) { additionalFields.put(paramName, request.getParameter(paramName)); }// w w w . ja v a 2 s . com } return additionalFields; }
From source file:com.smartgwt.extensions.fileuploader.server.TestServiceImpl.java
private void processQuery(HttpServletRequest request, HttpServletResponse response) { try {//from ww w. j a v a 2 s.co m System.out.println("--------------------------------------------"); for (Enumeration<String> en = request.getParameterNames(); en.hasMoreElements();) { String name = en.nextElement(); System.out.println(name + "=" + request.getParameter(name)); } // these are parameters I pass from my ProjectDataSource on all calls. Change to meet your needs. String context = request.getParameter("context"); String model = request.getParameter("model"); String xq = request.getParameter("xq"); String op = request.getParameter("_operationType"); response.setContentType("text/xml"); response.setHeader("Pragma", "No-cache"); response.setDateHeader("Expires", 0); response.setHeader("Cache-Control", "no-cache"); PrintWriter out = response.getWriter(); getResponse(out, context, model, xq, op); out.flush(); } catch (Exception e) { System.out.println(e.getMessage()); } }
From source file:gov.nih.nci.system.web.struts.action.UpdateAction.java
private Object prepareObject(HttpServletRequest request) throws Exception { StringBuilder sb = new StringBuilder(); Enumeration<String> parameters = request.getParameterNames(); Map<String, Map<String, List<Object>>> isoDataTypeNodes = new HashMap<String, Map<String, List<Object>>>(); Object instance = null;// ww w . j av a 2s .c om Class klass = Class.forName(target); instance = klass.newInstance(); while (parameters.hasMoreElements()) { String parameterName = (String) parameters.nextElement(); if (!parameterName.equals("klassName") && !parameterName.equals("searchObj") && !parameterName.equals("BtnSearch") && !parameterName.equals("username") && !parameterName.equals("password") && !parameterName.equals("selectedDomain")) { String parameterValue = (request.getParameter(parameterName)).trim(); setParameterValue(klass, instance, parameterName, parameterValue); } } return instance; }
From source file:org.bedework.eventreg.web.AbstractController.java
/** * @param req request/*from w w w. ja v a 2 s .co m*/ */ public void dumpRequest(final HttpServletRequest req) { try { @SuppressWarnings("unchecked") final Enumeration<String> names = req.getParameterNames(); final String title = "Request parameters"; debug(title + " - global info and uris"); debug("getRequestURI = " + req.getRequestURI()); debug("getRemoteUser = " + req.getRemoteUser()); debug("getRequestedSessionId = " + req.getRequestedSessionId()); debug("HttpUtils.getRequestURL(req) = " + req.getRequestURL()); debug("query=" + req.getQueryString()); debug("contentlen=" + req.getContentLength()); debug("request=" + req); debug("parameters:"); debug(title); while (names.hasMoreElements()) { final String key = names.nextElement(); final String[] vals = req.getParameterValues(key); for (final String val : vals) { debug(" " + key + " = \"" + val + "\""); } } } catch (final Throwable t) { error(t); } }