List of usage examples for javax.servlet.http HttpServletRequest getParameterValues
public String[] getParameterValues(String name);
String
objects containing all of the values the given request parameter has, or null
if the parameter does not exist. From source file:com.virtusa.akura.attendance.controller.TeacherAttendanceController.java
/** * method to save or update teacher attendance object. * // w w w . j a v a 2s.c om * @param request Http request. * @param map model map to set data. * @return String value of jsp page to direct. * @throws AkuraAppException throw exception if occur. */ @RequestMapping(method = RequestMethod.POST, value = REQ_VALUE_SAVEORUPDATE_TEACHER_ATTENDANCE) public String saveorupdateTeacherAttendance(HttpServletRequest request, ModelMap map) throws AkuraAppException { String[] staffIdList = request.getParameterValues(STAFF_ID_LIST); String staffType = request.getParameter(SELECT); // selected date String date = request.getParameter(DATE); // get the daily teacher attendance list for given date and staff type List<DailyTeacherAttendance> dailyTeacherAttendanceList = dailyAttendanceService .getTeacherAttandanceList(DateUtil.getParseDate(date), Boolean.parseBoolean(staffType)); // get teacher list who are on half-day. List<StaffLeave> halfdayTeacherAttendanceList = dailyAttendanceService .gethalfDayTeacherAttandanceList(DateUtil.getParseDate(date), Boolean.parseBoolean(staffType)); List<String> pastAttendanceList = new ArrayList<String>(); List<String> halfDayTeacherList = new ArrayList<String>(); // get the present teacher id list for (DailyTeacherAttendance dailyAttendanceList : dailyTeacherAttendanceList) { pastAttendanceList.add(dailyAttendanceList.getStaffId().toString()); } // get the half-day teacher id list for (StaffLeave dailyAttendanceList : halfdayTeacherAttendanceList) { Integer intObj = new Integer(dailyAttendanceList.getStaffId()); halfDayTeacherList.add(intObj.toString()); } try { if (staffIdList != null) { // selected staffType @SuppressWarnings("unchecked") // get the absent teachers list List<String> toBeRemoved = ListUtils.subtract((pastAttendanceList), Arrays.asList(staffIdList)); @SuppressWarnings("unchecked") // get the present teachers list List<String> toBeAdd = ListUtils.subtract(Arrays.asList(staffIdList), pastAttendanceList); @SuppressWarnings("unchecked") List<String> toBeAddWithOutHalfDay = ListUtils.subtract(toBeAdd, halfDayTeacherList); @SuppressWarnings("unchecked") // To be added staff with approved half day leave List<String> toBeAddWithHalfDay = ListUtils.subtract(toBeAdd, toBeAddWithOutHalfDay); // add present teachers if (!toBeAddWithOutHalfDay.isEmpty() || !toBeAddWithHalfDay.isEmpty()) { String timeIn = PropertyReader.getPropertyValue(SYSTEM_CONFIG, DEFAULT_TIME_IN); String timeOut = PropertyReader.getPropertyValue(SYSTEM_CONFIG, DEFAULT_TIME_OUT); String timeInHlfDay = PropertyReader.getPropertyValue(SYSTEM_CONFIG, DEFAULT_TIME_IN_HLFDAY); String timeOutHlfDay = PropertyReader.getPropertyValue(SYSTEM_CONFIG, DEFAULT_TIME_OUT_HLFDAY); List<DailyTeacherAttendance> saveList = new ArrayList<DailyTeacherAttendance>(); for (String presentTeacherId : toBeAddWithOutHalfDay) { DailyTeacherAttendance dailyTeacherAttendance = new DailyTeacherAttendance(); dailyTeacherAttendance.setStaffId(Integer.valueOf(presentTeacherId)); dailyTeacherAttendance.setDate(DateUtil.getParseDate(date)); dailyTeacherAttendance.setTimeIn(timeIn); dailyTeacherAttendance.setTimeOut(timeOut); saveList.add(dailyTeacherAttendance); } // add halfday teachers to DB for (String presentTeacherId : toBeAddWithHalfDay) { DailyTeacherAttendance dailyTeacherAttendanceH = new DailyTeacherAttendance(); dailyTeacherAttendanceH.setStaffId(Integer.valueOf(presentTeacherId)); dailyTeacherAttendanceH.setDate(DateUtil.getParseDate(date)); dailyTeacherAttendanceH.setTimeIn(timeInHlfDay); dailyTeacherAttendanceH.setTimeOut(timeOutHlfDay); saveList.add(dailyTeacherAttendanceH); } dailyAttendanceService.saveDailyTeacherAttendance(saveList); } // remove absent teachers if (!toBeRemoved.isEmpty()) { deleteAbsentTeachers(date, toBeRemoved); } return searchTeacherAttendance(request, map); } else if (staffIdList == null && (!dailyTeacherAttendanceList.isEmpty())) { deleteAbsentTeachers(date, pastAttendanceList); return searchTeacherAttendance(request, map); } } catch (AkuraAppException e) { if (e.getCause() instanceof DataIntegrityViolationException) { String message = new ErrorMsgLoader().getErrorMessage(ATTENDANCE_SAVE_FAIL); map.addAttribute(MESSAGE, message); return ATTENDANCE_DAILY_ATTENDANCE; } else { throw e; } } return searchTeacherAttendance(request, map); }
From source file:com.adito.boot.Util.java
/** * Dump all request parameters to {@link System#err} * /* w w w .j a v a 2 s . co m*/ * @param request request to get parameters from */ public static void dumpRequestParameters(HttpServletRequest request) { System.err.println("Request parameters for session #" + request.getSession().getId()); for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) { String n = (String) e.nextElement(); String[] vals = request.getParameterValues(n); for (int i = 0; i < vals.length; i++) { System.err.println(" " + n + " = " + vals[i]); } } }
From source file:fr.paris.lutece.plugins.extend.modules.actionbar.web.component.ActionbarResourceExtenderComponent.java
/** * {@inheritDoc}/* w w w.jav a 2 s. c o m*/ */ @Override public void doSaveConfig(HttpServletRequest request, IExtenderConfig config) throws ExtendErrorException { String strAllActions = request.getParameter(PARAMETER_ALL_ACTIONS); ActionbarExtenderConfig actionbarExtenderConfig = (ActionbarExtenderConfig) config; if (Boolean.parseBoolean(strAllActions)) { actionbarExtenderConfig.setAllButtons(true); actionbarExtenderConfig.setListActionButtonId(new ArrayList<Integer>()); } else { actionbarExtenderConfig.setAllButtons(false); String[] strButtons = request.getParameterValues(PARAMETER_ACTION_BUTTON); if (strButtons != null && strButtons.length > 0) { List<Integer> listActionsButtonId = new ArrayList<Integer>(); for (String strActionId : strButtons) { listActionsButtonId.add(Integer.parseInt(strActionId)); } actionbarExtenderConfig.setListActionButtonId(listActionsButtonId); } else { actionbarExtenderConfig.setListActionButtonId(new ArrayList<Integer>()); } } _configService.update(actionbarExtenderConfig); }
From source file:com.sun.faban.harness.webclient.ResultAction.java
public String deleteResults(HttpServletRequest request, HttpServletResponse response) throws IOException { String[] runIds = request.getParameterValues("select"); if (runIds != null) { TagEngine tagEngine;/* ww w. j a va2s. co m*/ try { tagEngine = TagEngine.getInstance(); } catch (ClassNotFoundException ex) { logger.log(Level.SEVERE, "Cannot find tag engine class", ex); throw new IOException("Cannot find tag engine class", ex); } for (String r : runIds) { RunResult runResult = RunResult.getInstance(new RunId(r)); runResult.delete(r); tagEngine.removeRun(r); tagEngine.save(); } } HttpSession session = request.getSession(); UserEnv usrEnv = (UserEnv) session.getAttribute("usrEnv"); if (usrEnv == null) { usrEnv = new UserEnv(); session.setAttribute("usrEnv", usrEnv); } SortableTableModel resultTable = RunResult.getResultTable(usrEnv.getSubject(), 5, "DESCENDING"); String feedURL = "/controller/results/feed"; request.setAttribute("feedURL", feedURL); request.setAttribute("table.model", resultTable); return "/resultlist.jsp"; }
From source file:net.oauth.signature.GoogleCodeCompatibilityTests.java
/** * tests compatibility of calculating the signature base string. *//*from w w w . ja v a 2 s. c o m*/ @Test public void testCalculateSignatureBaseString() throws Exception { final String baseUrl = "http://www.springframework.org/schema/security/"; CoreOAuthProviderSupport support = new CoreOAuthProviderSupport() { @Override protected String getBaseUrl(HttpServletRequest request) { return baseUrl; } }; Map<String, String[]> parameterMap = new HashMap<String, String[]>(); parameterMap.put("a", new String[] { "value-a" }); parameterMap.put("b", new String[] { "value-b" }); parameterMap.put("c", new String[] { "value-c" }); parameterMap.put("param[1]", new String[] { "aaa", "bbb" }); when(request.getParameterNames()).thenReturn(Collections.enumeration(parameterMap.keySet())); for (Map.Entry<String, String[]> param : parameterMap.entrySet()) { when(request.getParameterValues(param.getKey())).thenReturn(param.getValue()); } String header = "OAuth realm=\"http://sp.example.com/\"," + " oauth_consumer_key=\"0685bd9184jfhq22\"," + " oauth_token=\"ad180jjd733klru7\"," + " oauth_signature_method=\"HMAC-SHA1\"," + " oauth_signature=\"wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D\"," + " oauth_timestamp=\"137131200\"," + " oauth_callback=\"" + OAuthCodec.oauthEncode("http://myhost.com/callback") + "\"," + " oauth_nonce=\"4572616e48616d6d65724c61686176\"," + " oauth_version=\"1.0\""; when(request.getHeaders("Authorization")).thenReturn(Collections.enumeration(Arrays.asList(header))); when(request.getMethod()).thenReturn("GET"); String ours = support.getSignatureBaseString(request); when(request.getHeaders("Authorization")).thenReturn(Collections.enumeration(Arrays.asList(header))); when(request.getParameterMap()).thenReturn(parameterMap); when(request.getHeaderNames()).thenReturn(null); OAuthMessage message = OAuthServlet.getMessage(request, baseUrl); String theirs = OAuthSignatureMethod.getBaseString(message); assertEquals(theirs, ours); }
From source file:fr.paris.lutece.plugins.workflow.modules.notifymylutece.web.NotifyMyLuteceTaskComponent.java
/** * Get the selected users/*from ww w .j av a 2 s . co m*/ * @param request the HTTP request * @param config the config * @return a list of User Guid */ private String[] getSelectedUsers(HttpServletRequest request, TaskNotifyMyLuteceConfig config) { // Init the list of user guid List<String> listUserGuid; if ((config.getListUserGuid() != null) && (config.getListUserGuid().length > 0)) { listUserGuid = new ArrayList<String>(Arrays.asList(config.getListUserGuid())); } else { listUserGuid = new ArrayList<String>(); } // Remove unselected users from the list String[] listUnselectedUsers = request.getParameterValues(NotifyMyLuteceConstants.PARAMETER_UNSELECT_USERS); if ((listUnselectedUsers != null) && (listUnselectedUsers.length > 0)) { if ((listUserGuid != null) && !listUserGuid.isEmpty()) { for (String strUserGuid : listUnselectedUsers) { listUserGuid.remove(strUserGuid); } } } // Add selected users String[] listSelectedUsers = request.getParameterValues(NotifyMyLuteceConstants.PARAMETER_SELECT_USERS); if ((listSelectedUsers != null) && (listSelectedUsers.length > 0)) { for (String strUserGuid : listSelectedUsers) { listUserGuid.add(strUserGuid); } } if ((listUserGuid != null) && !listUserGuid.isEmpty()) { return listUserGuid.toArray(new String[listUserGuid.size()]); } return null; }
From source file:fr.paris.lutece.portal.web.features.RightJspBean.java
/** * Process the data capture form for assign users to a role * * @param request The HTTP Request//w w w.j ava2 s . c om * @return The Jsp URL of the process result */ public String doAssignUsers(HttpServletRequest request) { String strReturn; String strActionCancel = request.getParameter(PARAMETER_CANCEL); if (strActionCancel != null) { strReturn = JSP_URL_RIGHTS_MANAGEMENT; } else { String strIdRight = request.getParameter(PARAMETER_ID_RIGHT); //retrieve the selected portlets ids String[] arrayUsersIds = request.getParameterValues(PARAMETER_AVAILABLE_USER_LIST); if ((arrayUsersIds != null)) { for (int i = 0; i < arrayUsersIds.length; i++) { int nUserId = Integer.parseInt(arrayUsersIds[i]); AdminUser user = AdminUserHome.findByPrimaryKey(nUserId); if (!AdminUserHome.hasRight(user, strIdRight)) { AdminUserHome.createRightForUser(nUserId, strIdRight); } } } strReturn = JSP_ASSIGN_USERS_TO_RIGHT + "?" + PARAMETER_ID_RIGHT + "=" + strIdRight; } return strReturn; }
From source file:com.myapp.dao.SalesOrderDAO.java
public int addToDb(HttpServletRequest request) throws SQLException, IOException { String dburl = "jdbc:mysql://localhost:3306/moviedb"; String dbuser = "root"; String dbpassword = "Windows@123"; String dbdriver = "com.mysql.jdbc.Driver"; int result = 0; Statement statement = null;/* w w w. j a v a 2 s . c o m*/ // int numberOfItr = Integer.parseInt(request.getParameter("count")); Connection conn = DAO.getConnectionJDBC(dburl, dbuser, dbpassword, dbdriver); String SalesOrderIDlist[] = request.getParameterValues("SalesOrderID"); String RevisionNumberlist[] = request.getParameterValues("RevisionNumber"); String OrderDatelist[] = request.getParameterValues("OrderDate"); String DueDatelist[] = request.getParameterValues("DueDate"); String ShipDatelist[] = request.getParameterValues("ShipDate"); String Statuslist[] = request.getParameterValues("Status"); String OnlineOrderFlaglist[] = request.getParameterValues("OnlineOrderFlag"); String SalesOrderNumberlist[] = request.getParameterValues("SalesOrderNumber"); String PurchaseOrderNumberlist[] = request.getParameterValues("PurchaseOrderNumber"); String AccountNumberlist[] = request.getParameterValues("AccountNumber"); String CustomerIDlist[] = request.getParameterValues("CustomerID"); String SalesPersonIDlist[] = request.getParameterValues("SalesPersonID"); String TerritoryIDlist[] = request.getParameterValues("TerritoryID"); String BillToAddressIDlist[] = request.getParameterValues("BillToAddressID"); String ShipToAddressIDlist[] = request.getParameterValues("ShipToAddressID"); String ShipMethodIDlist[] = request.getParameterValues("ShipMethodID"); String CreditCardIDlist[] = request.getParameterValues("CreditCardID"); String CreditCardApprovalCodelist[] = request.getParameterValues("CreditCardApprovalCode"); String CurrencyRateIDlist[] = request.getParameterValues("CurrencyRateID"); String SubTotallist[] = request.getParameterValues("SubTotal"); String TaxAmtlist[] = request.getParameterValues("TaxAmt"); String Freightlist[] = request.getParameterValues("Freight"); String TotalDuelist[] = request.getParameterValues("TotalDue"); String Commentlist[] = request.getParameterValues("Comment"); String ModifiedDatelist[] = request.getParameterValues("ModifiedDate"); for (int i = 0; i < SalesOrderIDlist.length; i++) { String queryMessage = "INSERT INTO SalesOrder (SalesOrderID, " + "RevisionNumber, OrderDate, DueDate, ShipDate, Status," + " OnlineOrderFlag, SalesOrderNumber, PurchaseOrderNumber, " + " AccountNumber, CustomerID, SalesPersonID, " + "TerritoryID, BillToAddressID, ShipToAddressID, ShipMethodID, " + "CreditCardID, CreditCardApprovalCode, CurrencyRateID," + " SubTotal, TaxAmt, Freight, TotalDue, Comment, ModifiedDate)" + "values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; // statement = conn.createStatement(); PreparedStatement msgStmt = conn.prepareStatement(queryMessage); msgStmt.setString(1, SalesOrderIDlist[i]); msgStmt.setString(2, RevisionNumberlist[i]); msgStmt.setString(3, OrderDatelist[i]); msgStmt.setString(4, DueDatelist[i]); msgStmt.setString(5, ShipDatelist[i]); msgStmt.setString(6, Statuslist[i]); msgStmt.setString(7, OnlineOrderFlaglist[i]); msgStmt.setString(8, SalesOrderNumberlist[i]); msgStmt.setString(9, PurchaseOrderNumberlist[i]); msgStmt.setString(10, AccountNumberlist[i]); msgStmt.setString(11, CustomerIDlist[i]); msgStmt.setString(12, SalesPersonIDlist[i]); msgStmt.setString(13, TerritoryIDlist[i]); msgStmt.setString(14, BillToAddressIDlist[i]); msgStmt.setString(15, ShipToAddressIDlist[i]); msgStmt.setString(16, ShipMethodIDlist[i]); msgStmt.setString(17, CreditCardIDlist[i]); msgStmt.setString(18, CreditCardApprovalCodelist[i]); msgStmt.setString(19, CurrencyRateIDlist[i]); msgStmt.setString(20, SubTotallist[i]); msgStmt.setString(21, TaxAmtlist[i]); msgStmt.setString(22, Freightlist[i]); msgStmt.setString(23, TotalDuelist[i]); msgStmt.setString(24, Commentlist[i]); msgStmt.setString(25, ModifiedDatelist[i]); result = msgStmt.executeUpdate(); } return result; }
From source file:com.bitranger.parknshop.common.service.ItemFinderService.java
/** * return the list of the items/*w w w .ja v a2s. c o m*/ * @param request * @return */ public List<PsItem> getItems(HttpServletRequest request) { // /itemlist?searchBar=drgsdfsd&searchBtn=Search // /itemlist?category_id=4&page_number=2&order_by=vote&asd=desc# String key = request.getParameter("searchBar"); if (Str.Utils.notBlank(key)) { System.out.println("ItemFinderService.getItems()" + key); System.out.println(itemFinder.newFind().search(key).size()); return itemFinder.newFind().search(key); } return this.categoryId(request.getParameter(Names.params.categoryId)) .tagIds(request.getParameterValues(Names.params.tag)) .maxPrice(request.getParameter(Names.params.maxPrice)) .minPrice(request.getParameter(Names.params.minPrice)) .pageNumber(request.getParameter(Names.params.pageNumber)) .orderBy(request.getParameter(Names.params.orderBy)).asd(request.getParameter(Names.params.asd)) .list(); }
From source file:com.ikon.servlet.frontend.DownloadServlet.java
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.debug("service({}, {})", request, response); request.setCharacterEncoding("UTF-8"); String path = request.getParameter("path"); String uuid = request.getParameter("uuid"); String[] uuidList = request.getParameterValues("uuidList"); String[] pathList = request.getParameterValues("pathList"); String checkout = request.getParameter("checkout"); String ver = request.getParameter("ver"); boolean export = request.getParameter("export") != null; boolean inline = request.getParameter("inline") != null; File tmp = File.createTempFile("okm", ".tmp"); Document doc = null;// w w w. j a v a 2s . co m InputStream is = null; updateSessionManager(request); try { // Now an document can be located by UUID if (uuid != null && !uuid.equals("")) { path = OKMRepository.getInstance().getNodePath(null, uuid); } else if (path != null) { path = new String(path.getBytes("ISO-8859-1"), "UTF-8"); } if (export) { if (exportZip) { String fileName = "export.zip"; // Get document FileOutputStream os = new FileOutputStream(tmp); if (path != null) { exportFolderAsZip(path, os); fileName = PathUtils.getName(path) + ".zip"; } else if (uuidList != null || pathList != null) { // Export into a zip file multiple documents List<String> paths = new ArrayList<String>(); if (uuidList != null) { for (String uuidElto : uuidList) { String foo = new String(uuidElto.getBytes("ISO-8859-1"), "UTF-8"); paths.add(OKMRepository.getInstance().getNodePath(null, foo)); } } else if (pathList != null) { for (String pathElto : pathList) { String foo = new String(pathElto.getBytes("ISO-8859-1"), "UTF-8"); paths.add(foo); } } fileName = PathUtils.getName(PathUtils.getParent(paths.get(0))); exportDocumentsAsZip(paths, os, fileName); fileName += ".zip"; } os.flush(); os.close(); is = new FileInputStream(tmp); // Send document WebUtils.sendFile(request, response, fileName, MimeTypeConfig.MIME_ZIP, inline, is); } else if (exportJar) { // Get document FileOutputStream os = new FileOutputStream(tmp); exportFolderAsJar(path, os); os.flush(); os.close(); is = new FileInputStream(tmp); // Send document String fileName = PathUtils.getName(path) + ".jar"; WebUtils.sendFile(request, response, fileName, "application/x-java-archive", inline, is); } } else { // Get document doc = OKMDocument.getInstance().getProperties(null, path); if (ver != null && !ver.equals("")) { is = OKMDocument.getInstance().getContentByVersion(null, path, ver); } else { is = OKMDocument.getInstance().getContent(null, path, checkout != null); } // Send document String fileName = PathUtils.getName(doc.getPath()); WebUtils.sendFile(request, response, fileName, doc.getMimeType(), inline, is); UserActivity.log(request.getRemoteUser(), "DOWNLOAD_DOCUMENT", uuid, path, null); } } catch (PathNotFoundException e) { log.warn(e.getMessage(), e); throw new ServletException(new OKMException( ErrorCode.get(ErrorCode.ORIGIN_OKMDownloadService, ErrorCode.CAUSE_PathNotFound), e.getMessage())); } catch (RepositoryException e) { log.warn(e.getMessage(), e); throw new ServletException( new OKMException(ErrorCode.get(ErrorCode.ORIGIN_OKMDownloadService, ErrorCode.CAUSE_Repository), e.getMessage())); } catch (IOException e) { log.error(e.getMessage(), e); throw new ServletException(new OKMException( ErrorCode.get(ErrorCode.ORIGIN_OKMDownloadService, ErrorCode.CAUSE_IO), e.getMessage())); } catch (DatabaseException e) { log.error(e.getMessage(), e); throw new ServletException(new OKMException( ErrorCode.get(ErrorCode.ORIGIN_OKMDownloadService, ErrorCode.CAUSE_Database), e.getMessage())); } catch (Exception e) { log.error(e.getMessage(), e); throw new ServletException(new OKMException( ErrorCode.get(ErrorCode.ORIGIN_OKMDownloadService, ErrorCode.CAUSE_General), e.getMessage())); } finally { IOUtils.closeQuietly(is); FileUtils.deleteQuietly(tmp); } log.debug("service: void"); }