@Override public void populate(HttpServletRequest request) { super.populate(request); if (StringUtils.isNotBlank( request.getParameter(KRADConstants.TableRenderConstants.VIEWED_PAGE_NUMBER))) { setViewedPageNumber( Integer.parseInt( request.getParameter(KRADConstants.TableRenderConstants.VIEWED_PAGE_NUMBER))); } else { setViewedPageNumber(0); // first page is page 0 } if (KRADConstants.TableRenderConstants.SWITCH_TO_PAGE_METHOD.equals(getMethodToCall())) { final String paramPrefix = KRADConstants.DISPATCH_REQUEST_PARAMETER + "." + KRADConstants.TableRenderConstants.SWITCH_TO_PAGE_METHOD + "."; setSwitchToPageNumber( PagingBannerUtils.getNumbericalValueAfterPrefix( paramPrefix, request.getParameterNames())); if (getSwitchToPageNumber() == -1) { throw new RuntimeException("Couldn't find page number"); } } if (KRADConstants.TableRenderConstants.SORT_METHOD.equals(getMethodToCall())) { final String paramPrefix = KRADConstants.DISPATCH_REQUEST_PARAMETER + "." + KRADConstants.TableRenderConstants.SORT_METHOD + "."; setColumnToSortIndex( PagingBannerUtils.getNumbericalValueAfterPrefix( paramPrefix, request.getParameterNames())); if (getColumnToSortIndex() == -1) { throw new RuntimeException("Couldn't find column to sort"); } } setPreviouslySelectedObjectIdSet(parsePreviouslySelectedObjectIds(request)); setSelectedObjectIdSet(parseSelectedObjectIdSet(request)); setDisplayedObjectIdSet(parseDisplayedObjectIdSet(request)); setSearchUsingOnlyPrimaryKeyValues(parseSearchUsingOnlyPrimaryKeyValues(request)); if (isSearchUsingOnlyPrimaryKeyValues()) { setPrimaryKeyFieldLabels(getLookupable().getPrimaryKeyFieldLabels()); } }
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String param = ""; java.util.Enumeration<String> names = request.getParameterNames(); if (names.hasMoreElements()) { param = names.nextElement(); // just grab first element } org.owasp.benchmark.helpers.ThingInterface thing = org.owasp.benchmark.helpers.ThingFactory.createThing(); String bar = thing.doSomething(param); try { java.nio.file.Path path = java.nio.file.Paths.get(org.owasp.benchmark.helpers.Utils.testfileDir + bar); java.io.InputStream is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ); } catch (Exception e) { // OK to swallow any exception for now // TODO: Fix this, if possible. System.out.println("File exception caught and swallowed: " + e.getMessage()); } }
/** Servlet GET request: handles event requests. */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Event event = null; try { // Event parm identifies event type from the client String eventType = Servlets.getParameter(request, P_EVENT); // Always must have an event type if (eventType == null) { Log.warn("Pushlet.doGet(): bad request, no event specified"); response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No eventType specified"); return; } // Create Event and set attributes from parameters event = new Event(eventType); for (Enumeration e = request.getParameterNames(); e.hasMoreElements(); ) { String nextAttribute = (String) e.nextElement(); event.setField(nextAttribute, request.getParameter(nextAttribute)); } } catch (Throwable t) { // Error creating event Log.warn("Pushlet: Error creating event in doGet(): ", t); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return; } // Handle parsed request doRequest(event, request, response); }
/** @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response) */ protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Session s = HibernateUtils.getSession(); int id; String attr = null; @SuppressWarnings("rawtypes") Enumeration lf = request.getParameterNames(); while (lf.hasMoreElements()) { attr = (String) lf.nextElement(); if (!("idinv").equals(attr)) { id = Integer.parseInt(attr); ImprimantesClient f = new ImprimantesClient(); f.setIdImprimante(id); f = ServiceImprimanteClient.rechercheImprimantesClient(s, f); ServiceImprimanteClient.removeImprimantesClient(s, f); } } request.setAttribute("messageAdd", "Supression faite avec succès..."); request.setAttribute( "inv", Utilitaire.setInventaire(s, Integer.parseInt(request.getParameter("idinv")))); request .getServletContext() .getRequestDispatcher("/modificationInventaire.jsp") .forward(request, response); s.close(); }
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String param = ""; java.util.Enumeration<String> names = request.getParameterNames(); if (names.hasMoreElements()) { param = names.nextElement(); // just grab first element } String bar = new Test().doSomething(param); // Create the file first so the test won't throw an exception if it doesn't exist. // Note: Don't actually do this because this method signature could cause a tool to find THIS // file constructor // as a vuln, rather than the File signature we are trying to actually test. // If necessary, just run the benchmark twice. The 1st run should create all the necessary // files. // new java.io.File(org.owasp.benchmark.helpers.Utils.testfileDir + bar).createNewFile(); java.io.FileInputStream fileInputStream = new java.io.FileInputStream(org.owasp.benchmark.helpers.Utils.testfileDir + bar); java.io.FileDescriptor fd = fileInputStream.getFD(); java.io.FileOutputStream anotOutputStream = new java.io.FileOutputStream(fd); } // end doPost
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String param = ""; java.util.Enumeration<String> names = request.getParameterNames(); if (names.hasMoreElements()) { param = names.nextElement(); // just grab first element } String bar = doSomething(param); String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='******'"; try { java.sql.Connection connection = org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); java.sql.PreparedStatement statement = connection.prepareStatement( sql, java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY); statement.setString(1, "foo"); statement.execute(); } catch (java.sql.SQLException e) { throw new ServletException(e); } } // end doPost
private static void load(HttpServletRequest request, Builder b) { Enumeration<String> e = request.getHeaderNames(); String s; while (e.hasMoreElements()) { s = e.nextElement(); b.headers.put(s, request.getHeader(s)); } e = request.getAttributeNames(); while (e.hasMoreElements()) { s = e.nextElement(); b.localAttributes.put(s, attributeWithoutException(request, s)); } e = request.getParameterNames(); while (e.hasMoreElements()) { s = e.nextElement(); b.queryStrings.put(s, request.getParameterValues(s)); } b.queryString = request.getQueryString(); Enumeration<Locale> l = request.getLocales(); while (l.hasMoreElements()) { b.locale(l.nextElement()); } }
/* * Return a view sending all params from a request * * @param request HttpServletRequest to send to the view * @param viewname String with the view name to load * @return ModelAndView return a view with viewname */ public static ModelAndView buildViewParams(HttpServletRequest request, String viewname) { Map<String, Object> map = new HashMap<String, Object>(); ModelAndView mav = new ModelAndView(viewname, map); Enumeration<String> parameterNames = request.getParameterNames(); while (parameterNames.hasMoreElements()) { String paramName = parameterNames.nextElement(); // if the request var is a Array if ((request.getParameterValues(paramName).getClass().isArray()) // if Array size is more than 1 && (request.getParameterValues(paramName).length > 1)) { map.put(paramName, Arrays.toString(request.getParameterValues(paramName))); } else // if the request var is a simple var map.put(paramName, request.getParameter(paramName)); } mav.addAllObjects(map); // return view return mav; }
public void save(HttpServletRequest request) { for (Enumeration<?> e = request.getParameterNames(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); if (key.startsWith("p_")) { String value = request.getParameter(key); String name = key.substring(key.indexOf('_') + 1); Config entry = this.repository.getByName(name); if (entry == null) { entry = new Config(); entry.setName(name); } entry.setValue(value); this.config.clearProperty(name); this.config.setProperty(name, value); this.repository.update(entry); } } this.i18n.changeBoardDefaultLanguage(this.config.getValue(ConfigKeys.I18N_DEFAULT)); }
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String param = ""; java.util.Enumeration<String> names = request.getParameterNames(); if (names.hasMoreElements()) { param = names.nextElement(); // just grab first element } String bar; // Simple if statement that assigns param to bar on true condition int i = 196; if ((500 / 42) + i > 200) bar = param; else bar = "This should never happen"; String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='******'"; try { java.sql.Connection connection = org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection(); java.sql.PreparedStatement statement = connection.prepareStatement(sql); statement.setString(1, "foo"); statement.execute(); } catch (java.sql.SQLException e) { throw new ServletException(e); } }
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String targetModel = getServletConfig().getInitParameter("targetModel"); if (targetModel != null) { StringBuilder targetUri = new StringBuilder("/model.do?model="); targetUri.append(targetModel); for (Enumeration params = request.getParameterNames(); params.hasMoreElements(); ) { String paramName = (String) params.nextElement(); String paramValue = request.getParameter(paramName); targetUri.append("&" + paramName + "=" + paramValue); } RequestDispatcher rd = request.getRequestDispatcher(targetUri.toString()); rd.forward(request, response); return; } throw new ServletException("No target specified"); }
/** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (request.getCharacterEncoding() == null) request.setCharacterEncoding("UTF-8"); response.setContentType("application/json;charset=UTF-8"); response.setCharacterEncoding("UTF-8"); JSONObject ret = new JSONObject(); PrintWriter out = response.getWriter(); Enumeration<String> enumTest = request.getParameterNames(); HashMap<String, Object> requestMap = new HashMap<String, Object>(); while (enumTest.hasMoreElements()) { String tmp = enumTest.nextElement().toString(); requestMap.put(tmp, request.getParameter(tmp)); } try { Kayttaja kayttaja = new Kayttaja(SecurityContextHolder.getContext().getAuthentication().getName()); int orgId = Integer.parseInt(requestMap.get("org_id").toString()); String lang = requestMap.get("lang").toString(); if (lang == null || lang == "") lang = "fi"; org = new Organisation(lang); MapData md = new MapData(lang); ret = md.getExtentByType(MapData.TYPE_ORGANISATIONS, orgId); ret.put("success", true); out.println(ret.toString()); } catch (Exception e) { log.error(ExceptionUtils.getStackTrace(e)); out.println("{'success':'false', 'msg': 'Tapahtui odottamaton virhe sovelluksessa.'}"); } }
public ServletRequestCopy(HttpServletRequest request) { this.servletPath = request.getServletPath(); this.contextPath = request.getContextPath(); this.pathInfo = request.getPathInfo(); this.requestUri = request.getRequestURI(); this.requestURL = request.getRequestURL(); this.method = request.getMethod(); this.serverName = request.getServerName(); this.serverPort = request.getServerPort(); HttpSession session = request.getSession(true); httpSession = new HttpSessionCopy(session); String s; Enumeration<String> e = request.getHeaderNames(); while (e != null && e.hasMoreElements()) { s = e.nextElement(); Enumeration<String> headerValues = request.getHeaders(s); this.headers.put(s, headerValues); } e = request.getAttributeNames(); while (e != null && e.hasMoreElements()) { s = e.nextElement(); attributes.put(s, request.getAttribute(s)); } e = request.getParameterNames(); while (e != null && e.hasMoreElements()) { s = e.nextElement(); parameters.put(s, request.getParameterValues(s)); } }
private void logRequest(HttpServletRequest request) { if (logger.isInfoEnabled()) { logger.info("Request method: " + request.getMethod()); logger.info("Request contextPath: " + request.getContextPath()); logger.info("Request pathInfo: " + request.getPathInfo()); logger.info("Request pathTranslated: " + request.getPathTranslated()); logger.info("Request queryString: " + request.getQueryString()); logger.info("Request requestURI: " + request.getRequestURI()); logger.info("Request requestURL: " + request.getRequestURL()); logger.info("Request servletPath: " + request.getServletPath()); Enumeration headers = request.getHeaderNames(); if (headers != null) { while (headers.hasMoreElements()) { Object headerName = headers.nextElement(); logger.info( "Request header " + headerName + ":" + request.getHeader((String) headerName)); } } Enumeration params = request.getParameterNames(); if (params != null) { while (params.hasMoreElements()) { Object paramName = params.nextElement(); logger.info( "Request parameter " + paramName + ":" + request.getParameter((String) paramName)); } } logger.info("- End of request -"); } }
/** * Obtain debug information from the servlet request object * * @param httpRequest * @return */ public static String deriveUsefulInfo(HttpServletRequest httpRequest) { StringBuilder sb = new StringBuilder(); sb.append("[").append(httpRequest.getContextPath()); sb.append(":cookies=").append(httpRequest.getCookies()).append(":headers="); // Append Header information Enumeration<?> en = httpRequest.getHeaderNames(); while (en.hasMoreElements()) { String headerName = (String) en.nextElement(); sb.append(headerName).append("="); // Ensure HTTP Basic Password is not logged if (headerName.contains("authorization") == false) sb.append(httpRequest.getHeader(headerName)).append(","); } sb.append("]"); // Append Request parameter information sb.append("[parameters="); Enumeration<?> enparam = httpRequest.getParameterNames(); while (enparam.hasMoreElements()) { String paramName = (String) enparam.nextElement(); String[] paramValues = httpRequest.getParameterValues(paramName); int len = paramValues != null ? paramValues.length : 0; for (int i = 0; i < len; i++) sb.append(paramValues[i]).append("::"); sb.append(","); } sb.append("][attributes="); // Append Request attribute information Enumeration<?> enu = httpRequest.getAttributeNames(); while (enu.hasMoreElements()) { String attrName = (String) enu.nextElement(); sb.append(attrName).append("="); sb.append(httpRequest.getAttribute(attrName)).append(","); } sb.append("]"); return sb.toString(); }
public static List<RequestKV> getParameterMap( HttpServletRequest req, Map<String, String> skipParam) { @SuppressWarnings("unchecked") Enumeration<String> it = req.getParameterNames(); Set<String> keys = new HashSet<String>(); List<RequestKV> list = new ArrayList<RequestKV>(); while (it.hasMoreElements()) { String key = it.nextElement(); if ((skipParam != null) && skipParam.containsKey(key)) { continue; } if (keys.contains(key)) { continue; } keys.add(key); String values[] = req.getParameterValues(key); if (!ArrayUtils.isEmpty(values)) { for (String v : values) { RequestKV kv = new RequestKV(key, v); list.add(kv); } } } return list; }
protected void populateBeanFromParams(Object bean, HttpServletRequest request) { Map params = request.getParameterMap(); Enumeration paramNames = request.getParameterNames(); while (paramNames.hasMoreElements()) { String key = ""; try { key = (String) paramNames.nextElement(); } catch (ClassCastException cce) { log.error("populateBeanFromParams() could not cast parameter name to String"); } String value = ""; if (key.equals(MULTIPLEXED_PARAMETER_NAME)) { String multiplexedStr = request.getParameterValues(key)[0]; Map paramMap = FormUtils.beanParamMapFromString(multiplexedStr); Iterator paramIt = paramMap.keySet().iterator(); while (paramIt.hasNext()) { String param = (String) paramIt.next(); String demultiplexedValue = (String) paramMap.get(param); FormUtils.beanSet(bean, param, demultiplexedValue); } } else { try { value = (String) request.getParameterValues(key)[0]; } catch (ClassCastException cce) { try { value = ((Integer) params.get(key)).toString(); } catch (ClassCastException ccf) { log.error("populateBeanFromParams() could not cast parameter name to String"); } } FormUtils.beanSet(bean, key, value); } } }
@SuppressWarnings("unchecked") private void parse(HttpServletRequest req) { Enumeration<String> params = req.getParameterNames(); int limit = 0; int pageNum = 0; while (params.hasMoreElements()) { String param = params.nextElement(); Object value = req.getParameter(param); if (value == null) continue; if (param.startsWith(QUERY_PREFIX)) { parseQuery(param, value); } else if (param.startsWith(ORDER_PREFIX)) { parsetOrder(param, (String) value); } else if (param.equals(pageParamName)) { pageNum = RequestUtils.getIntegerParameter(req, pageParamName); } else if (param.equals(limitParamName)) { limit = RequestUtils.getIntegerParameter(req, limitParamName); } else { // ignore other parameters } } IPage page = new DefaultPage(); if (limit != 0) { page.setLimit(limit); } if (pageNum != 0) { page.setPageNumber(pageNum); } super.setPage(page); }
@Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType(TEXT_HTML); Enumeration<String> parameterNames = req.getParameterNames(); Map<String, String> params = new HashMap<>(); while (parameterNames.hasMoreElements()) { String current = parameterNames.nextElement(); params.put(current, req.getParameter(current)); } if (params.get(LOGIN) != null) { UserDto userDto = userController.getByLogin(params.get(EMAIL)); User user = userDto.getUser(); if (user == null || !user.getPassword().equals(params.get(PASSWORD))) { req.setAttribute(LOGIN_FAILED, true); } else { HttpSession session = req.getSession(true); session.setAttribute(USER, user); } } if (params.get(REGISTER) != null) { resp.sendRedirect("/cafe/register"); } else { if (params.get(LOGOUT) != null) { HttpSession session = req.getSession(true); session.removeAttribute(USER); session.removeAttribute(ORDER); } RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(MAIN_JSP); dispatcher.forward(req, resp); } }
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); Enumeration values = req.getParameterNames(); String name = ""; String value = ""; String id = ""; while (values.hasMoreElements()) { name = ((String) values.nextElement()).trim(); value = req.getParameter(name).trim(); if (name.equals("id")) id = value; } if (url.equals("")) { url = getServletContext().getInitParameter("url"); cas_url = getServletContext().getInitParameter("cas_url"); } HttpSession session = null; session = req.getSession(false); if (session != null) { session.invalidate(); } res.sendRedirect(cas_url); return; }
private PostMethod convertHttpServletRequestToPostMethod(String url, HttpServletRequest request) { PostMethod postMethod = new PostMethod(url); for (Enumeration headers = request.getHeaderNames(); headers.hasMoreElements(); ) { String headerName = (String) headers.nextElement(); String headerValue = (String) request.getHeader(headerName); postMethod.addRequestHeader(headerName, headerValue); } postMethod.removeRequestHeader("Host"); postMethod.addRequestHeader("Host", request.getRequestURL().toString()); for (Enumeration names = request.getParameterNames(); names.hasMoreElements(); ) { String paramName = (String) names.nextElement(); String paramValue = (String) request.getParameter(paramName); postMethod.addParameter(paramName, paramValue); } StringBuilder requestBody = new StringBuilder(); try { BufferedReader reader = request.getReader(); String line; while (null != (line = reader.readLine())) { requestBody.append(line); } reader.close(); } catch (IOException e) { requestBody.append(""); } postMethod.setRequestEntity(new StringRequestEntity(requestBody.toString())); return postMethod; }
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String pathInfo = req.getPathInfo(); if (pathInfo.equals("/")) { HttpSession session = req.getSession(); if (session == null) { resp.setStatus(401); return; } String username = (String) session.getAttribute("username"); if (username == null) { resp.setStatus(401); return; } Map userMap = loadUserSettingsMap(username); if (userMap == null) { resp.setStatus(401); return; } Enumeration parameterNames = req.getParameterNames(); while (parameterNames.hasMoreElements()) { String parameterName = (String) parameterNames.nextElement(); userMap.put(parameterName, req.getParameter(parameterName)); } saveUserSettingsMap(username, userMap); return; } super.doPost(req, resp); }
@Override public Object resolveArgument( MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { System.out.println("resolveArgument"); CommandMap commandMap = new CommandMap(); HttpServletRequest request = (HttpServletRequest) webRequest.getNativeRequest(); Enumeration<?> enumeration = request.getParameterNames(); String key = null; String[] values = null; while (enumeration.hasMoreElements()) { key = (String) enumeration.nextElement(); values = request.getParameterValues(key); if (values != null) { commandMap.put(key, (values.length > 1) ? values : values[0]); } } return commandMap; }
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String param = ""; java.util.Enumeration<String> names = request.getParameterNames(); if (names.hasMoreElements()) { param = names.nextElement(); // just grab first element } String bar = doSomething(param); try { java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-512", "SUN"); } catch (java.security.NoSuchAlgorithmException e) { System.out.println( "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); throw new ServletException(e); } catch (java.security.NoSuchProviderException e) { System.out.println( "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)"); throw new ServletException(e); } response .getWriter() .println( "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed"); } // end doPost
public void testSetParameters() { HttpServletRequest request = createMock(HttpServletRequest.class); HashMap<String, Object> model = new HashMap<String, Object>(); 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); 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); }
public void testImplicitParams() throws Exception { HttpServletRequest request = createMock(HttpServletRequest.class); expect(request.getParameterNames()) .andReturn( new Enumeration<String>() { private String[] list = {"one", "two"}; int index; public boolean hasMoreElements() { return (index < list.length); } public String nextElement() { final String string = list[index]; index++; return string; } }); expect(request.getParameter("one")).andReturn("v1"); expect(request.getParameter("two")).andReturn("v2"); replay(request); final ModelMap modelMap = new ModelMap(); RequestModelHelper.setParameters(request, modelMap); assertEquals(2, modelMap.size()); verify(request); }
/** * 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) */ 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; }
public QueryFilter(HttpServletRequest request) { this.request = request; Enumeration<?> paramEnu = request.getParameterNames(); while (paramEnu.hasMoreElements()) { String paramName = (String) paramEnu.nextElement(); if (paramName.startsWith("Q_")) { String paramValue = request.getParameter(paramName); addFilter(paramName, paramValue); } } Integer start = Integer.valueOf(0); Integer limit = PagingBean.DEFAULT_PAGE_SIZE; String s_start = request.getParameter("start"); String s_limit = request.getParameter("limit"); if (StringUtils.isNotEmpty(s_start)) { start = new Integer(s_start); } if (StringUtils.isNotEmpty(s_limit)) { limit = new Integer(s_limit); } String sort = request.getParameter("sort"); String dir = request.getParameter("dir"); if ((StringUtils.isNotEmpty(sort)) && (StringUtils.isNotEmpty(dir))) { addSorted(sort, dir); } this.pagingBean = new PagingBean(start.intValue(), limit.intValue()); }
private ExtendedMap parseSimpleRequest(HttpServletRequest request, boolean keepEmpty) { ExtendedMap formItems = new ExtendedMap(keepEmpty); Enumeration paramNames = request.getParameterNames(); while (paramNames.hasMoreElements()) { String key = paramNames.nextElement().toString(); String[] paramValues = request.getParameterValues(key); if (paramValues != null) { if (paramValues.length == 1 && paramValues[0] != null) { String value = paramValues[0]; if (value.length() > 0) { if ("true".equals(value)) { formItems.putBoolean(key, true); } else if ("false".equals(value)) { formItems.putBoolean(key, false); } else { formItems.putString(key, value); } } else if (keepEmpty) { formItems.putString(key, value); } } else if (paramValues.length > 1) { formItems.put(key, paramValues); } } } return formItems; }
protected DataListBinder createDataListBinderFromRequestInternal( AppDefinition appDef, String datalistId, String binderId, HttpServletRequest request) { DataListBinder binder = null; if (binderId != null && binderId.trim().length() > 0) { // create binder binder = dataListService.getBinder(binderId); if (request != null) { // get request params Enumeration e = request.getParameterNames(); while (e.hasMoreElements()) { String paramName = (String) e.nextElement(); if (paramName.startsWith(PREFIX_BINDER_PROPERTY)) { String[] paramValue = (String[]) request.getParameterValues(paramName); String propName = paramName.substring(PREFIX_BINDER_PROPERTY.length()); String value = CsvUtil.getDeliminatedString(paramValue); if (value.contains(SecurityUtil.ENVELOPE) || value.contains(PropertyUtil.PASSWORD_PROTECTED_VALUE)) { DatalistDefinition datalist = datalistDefinitionDao.loadById(datalistId, appDef); if (datalist != null) { value = PropertyUtil.propertiesJsonStoreProcessing(datalist.getJson(), value); } } binder.setProperty(propName, AppUtil.processHashVariable(value, null, null, null)); } } } } return binder; }