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.esgf.legacydatacart.LegacyOldFileTemplateController.java
/** * queryStringInfo(HttpServletRequest request) * Private method that prints out the contents of the request. Used mainly for debugging. * //from w w w .j a v a 2s. com * @param request */ @SuppressWarnings("unchecked") public static void queryStringInfo(HttpServletRequest request) { System.out.println("--------Utils Query String Info--------"); Enumeration<String> paramEnum = request.getParameterNames(); while (paramEnum.hasMoreElements()) { String postContent = (String) paramEnum.nextElement(); System.out.println(postContent + "-->"); System.out.println(request.getParameter(postContent)); } System.out.println("--------End Utils Query String Info--------"); }
From source file:org.impalaframework.extension.mvc.util.RequestModelHelper.java
/** * /* www . j a v a2s .com*/ * @param logger * @param request */ public static void maybeDebugRequest(Log logger, HttpServletRequest request) { if (logger.isDebugEnabled()) { logger.debug("#####################################################################################"); logger.debug("---------------------------- Request details ---------------------------------------"); logger.debug("Request context path: " + request.getContextPath()); logger.debug("Request path info: " + request.getPathInfo()); logger.debug("Request path translated: " + request.getPathTranslated()); logger.debug("Request query string: " + request.getQueryString()); logger.debug("Request servlet path: " + request.getServletPath()); logger.debug("Request request URI: " + request.getRequestURI()); logger.debug("Request request URL: " + request.getRequestURL()); logger.debug("Request session ID: " + request.getRequestedSessionId()); logger.debug("------------------------------------------------ "); logger.debug("Parameters ------------------------------------- "); final Enumeration<String> parameterNames = request.getParameterNames(); Map<String, String> parameters = new TreeMap<String, String>(); while (parameterNames.hasMoreElements()) { String name = parameterNames.nextElement(); String value = request.getParameter(name); final String lowerCase = name.toLowerCase(); if (lowerCase.contains("password") || lowerCase.contains("cardnumber")) { value = "HIDDEN"; } parameters.put(name, value); } //now output final Set<String> parameterKeys = parameters.keySet(); for (String key : parameterKeys) { logger.debug(key + ": " + parameters.get(key)); } logger.debug("------------------------------------------------ "); Map<String, Object> attributes = new TreeMap<String, Object>(); logger.debug("Attributes ------------------------------------- "); final Enumeration<String> attributeNames = request.getAttributeNames(); while (attributeNames.hasMoreElements()) { String name = attributeNames.nextElement(); Object value = request.getAttribute(name); final String lowerCase = name.toLowerCase(); if (lowerCase.contains("password") || lowerCase.contains("cardnumber")) { value = "HIDDEN"; } attributes.put(name, value); } //now output final Set<String> keys = attributes.keySet(); for (String name : keys) { Object value = attributes.get(name); logger.debug(name + ": " + (value != null ? value.toString() : value)); } logger.debug("------------------------------------------------ "); logger.debug("#####################################################################################"); } else { if (logger.isInfoEnabled()) { logger.info( "#####################################################################################"); logger.info("Request query string: " + request.getQueryString()); logger.info("Request request URI: " + request.getRequestURI()); logger.info( "#####################################################################################"); } } }
From source file:fr.paris.lutece.plugins.asynchronousupload.service.AbstractAsynchronousUploadHandler.java
/** * Checks the request parameters to see if an upload submit has been * called./*from w w w .j a v a 2 s. co m*/ * * @param request the HTTP request * @return the name of the upload action, if any. Null otherwise. */ public String getUploadAction(HttpServletRequest request) { Enumeration<String> enumParamNames = request.getParameterNames(); while (enumParamNames.hasMoreElements()) { String paramName = enumParamNames.nextElement(); if (paramName.startsWith(getUploadSubmitPrefix()) || paramName.startsWith(getUploadDeletePrefix())) { return paramName; } } return null; }
From source file:net.sourceforge.subsonic.backend.controller.IPNController.java
private String createValidationURL(HttpServletRequest request) throws UnsupportedEncodingException { Enumeration<?> en = request.getParameterNames(); StringBuilder url = new StringBuilder(PAYPAL_URL).append("?cmd=_notify-validate"); String encoding = request.getParameter("charset"); if (encoding == null) { encoding = "ISO-8859-1"; }/*from w w w . j a va 2s . co m*/ while (en.hasMoreElements()) { String paramName = (String) en.nextElement(); String paramValue = request.getParameter(paramName); url.append("&").append(paramName).append("=").append(URLEncoder.encode(paramValue, encoding)); } return url.toString(); }
From source file:org.freeeed.search.web.controller.BaseController.java
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.request = request; this.response = response; valueStack = new HashMap<String, Object>(); Enumeration<String> en = request.getParameterNames(); while (en.hasMoreElements()) { String param = en.nextElement(); valueStack.put(param, request.getParameter(param)); }/*from w ww . j a v a2 s. com*/ ModelAndView modelAndView = execute(); valueStack.put("visitor", siteVisitor); valueStack.put("loggedVisitor", loggedSiteVisitor); if (addValueStackToModel()) { modelAndView.addAllObjects(valueStack); } return modelAndView; }
From source file:com.ms.commons.summer.web.handler.ObjectArrayDataBinder.java
@SuppressWarnings("unchecked") private int initParamAndValues(HttpServletRequest request, String name, Map<String, String[]> paramAndValues) { int size = -1; boolean checkPrefix = false; if (StringUtils.isNotEmpty(name)) { checkPrefix = true;/* w ww .ja v a2s . c o m*/ } for (Enumeration<String> parameterNames = request.getParameterNames(); parameterNames.hasMoreElements();) { String parameterName = parameterNames.nextElement(); if (checkPrefix && parameterName.startsWith(name + ".")) { String[] values = request.getParameterValues(parameterName); if (values != null && values.length > 0) { paramAndValues.put(parameterName.substring(name.length() + 1), values); if (size == -1) { size = values.length; } else if (size != values.length) { fieldError = new FieldError(name, name, "?"); return -1; } } } } return size; }
From source file:de.ifgi.mosia.wpswfs.BaseServlet.java
private RequestHandler resolveHandler(HttpServletRequest req) throws ServiceException { String request = req.getParameter("request"); if (request == null || request.isEmpty()) { Enumeration<?> it = req.getParameterNames(); while (it.hasMoreElements()) { String next = it.nextElement().toString(); if (next.equalsIgnoreCase("request")) { request = req.getParameter(next); break; }/*ww w . j ava 2 s.com*/ } } if (request == null || request.isEmpty()) { throw new ServiceException("The parameter 'request' was not provided"); } for (RequestHandler h : handlers) { if (h.supportsRequestType(request)) { return h; } } return null; }
From source file:com.dianping.lion.api.http.AbstractLionServlet.java
@SuppressWarnings("unchecked") protected String getParameterString(HttpServletRequest request) { StringBuilder builder = new StringBuilder(); Enumeration<String> parameterNames = request.getParameterNames(); int i = 0;//from w ww .j av a 2 s. c o m while (parameterNames.hasMoreElements()) { String parameterName = parameterNames.nextElement(); String[] parameterValues = request.getParameterValues(parameterName); for (String parameterValue : parameterValues) { builder.append(i++ > 0 ? "&" : StringUtils.EMPTY).append(parameterName).append("=") .append(parameterValue); } } return builder.toString(); }
From source file:com.github.jrialland.ajpclient.servlet.TestServletProxy.java
public TestServletProxy() { super(Protocol.Ajp); addStaticResource("/dizzy.mp4", DIZZY_MP4); addServlet("/test_post", new HttpServlet() { private static final long serialVersionUID = 168417L; @Override// w w w . j av a 2 s. co m protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { final int nParams = Collections.list(req.getParameterNames()).size(); resp.getWriter().print(nParams); } }); addServlet("/long_request", new HttpServlet() { private static final long serialVersionUID = 168411L; @Override protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { try { final int time = Integer.parseInt(req.getParameter("duration")); Thread.sleep(time); } catch (final Exception e) { throw new ServletException(e); } } }); }
From source file:com.viseur.control.AddDevItems.java
/** * Handles the HTTP <code>POST</code> method. * * @param request servlet request/*from w w w.j a va 2 s. c o m*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { JSONObject obj = new JSONObject(); try { obj.put("success", 2); } catch (JSONException ex) { } Enumeration<String> names = request.getParameterNames(); String para = names.nextElement(); String val = request.getParameter(para); DeveloperItems itm = new DeveloperItems(); switch (para) { case "lang": obj = new JSONObject(itm.addProgrammingLang(val)); break; case "opsys": obj = new JSONObject(itm.addOpSystem(val)); break; case "platform": obj = new JSONObject(itm.addPlatform(val)); break; } response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); try (PrintWriter out = response.getWriter()) { out.println(obj); } }