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.museum_web.controller.ScenarioController.java
@RequestMapping("actions/saveScenario") public void save(Scenario scenario, HttpServletRequest request, HttpServletResponse response) throws Exception { ScenarioBuilder sb = new ScenarioBuilder(); String[] objects = request.getParameterValues("Object"); String[] challenges = request.getParameterValues("Challenge"); List<Challenge> chs = new ArrayList<Challenge>(); List<MuseologicalObject> obs = new ArrayList<MuseologicalObject>(); if (objects != null) { for (String c : challenges) { Challenge cha = new ChallengeService().findById(Long.parseLong(c)); sb.withChallenge(cha);//from ww w.j a va 2 s .co m chs.add(cha); } } if (challenges != null) { for (String o : objects) { MuseologicalObject mus = new MuseologicalObjectService().findById(Long.parseLong(o)); sb.withObject(mus); obs.add(mus); } } Theme th = new ThemeService().findById(Long.parseLong(request.getParameter("idTheme"))); if (scenario.getId() == null) { sb.withTheme(th).build(scenario.getName(), scenario.getIdMuseum()); } else { ScenarioChallenge sc = new ScenarioChallenge(); sc.setChallenges(chs); sc.setObjects(obs); sc.setTheme(th); sc.setId(scenario.getId()); sc.setName(scenario.getName()); sc.setIdMuseum(scenario.getIdMuseum()); new ScenarioService().editScenario(sc); } sc = new Scenario(); response.sendRedirect("../scenario"); }
From source file:com.webpagebytes.cms.controllers.Statistics.java
public void getStatistics(HttpServletRequest request, HttpServletResponse response, String requestUri) throws WPBException { String[] entities = request.getParameterValues(PARAM_ENTITY); org.json.JSONObject payloadJson = new org.json.JSONObject(); try {/*w w w .j av a 2s . co m*/ if (entities != null) { for (String entity : entities) { entity = entity.toUpperCase(); WBEntities paramEntity = WBEntities.valueOf(entity.toUpperCase()); switch (paramEntity) { case URIS: getRecordsStats(request, WPBUri.class, payloadJson, entity); break; case PAGES: getRecordsStats(request, WPBPage.class, payloadJson, entity); break; case MODULES: getRecordsStats(request, WPBPageModule.class, payloadJson, entity); break; case ARTICLES: getRecordsStats(request, WPBArticle.class, payloadJson, entity); break; case FILES: getRecordsStats(request, WPBFile.class, payloadJson, entity); break; case LANGUAGES: getLanguagesStats(request, payloadJson, entity); break; case GLOBALPARAMS: break; } } } org.json.JSONObject returnJson = new org.json.JSONObject(); returnJson.put(DATA, payloadJson); httpServletToolbox.writeBodyResponseAsJson(response, returnJson, null); } catch (Exception e) { Map<String, String> errors = new HashMap<String, String>(); errors.put("", WPBErrors.WB_CANT_GET_RECORDS); httpServletToolbox.writeBodyResponseAsJson(response, jsonObjectConverter.JSONObjectFromMap(null), errors); } }
From source file:com.dianping.lion.api.http.AbstractLionServlet.java
protected String[] getRequiredParameters(HttpServletRequest servletRequest, String param) { String[] paramVals = servletRequest.getParameterValues(param); if (paramVals == null || paramVals.length == 0) { throw new RuntimeBusinessException("Parameter[" + param + "] is required."); }// w ww. j av a 2 s . c om return paramVals; }
From source file:com.itesm.test.servlets.TasksServlet.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String[] description = request.getParameterValues("description"); String[] priority = request.getParameterValues("priority"); String[] task_time = request.getParameterValues("task_time"); String[] end_time = request.getParameterValues("end_time"); PersonaVO personavo = (PersonaVO) request.getSession().getAttribute("persona"); TaskManager taskManager = new TaskManager(); for (int i = 0; i < priority.length; i++) { TaskVO wh = new TaskVO(); SimpleDateFormat sdf = new SimpleDateFormat("hh:mm"); SimpleDateFormat sdfTimeStamp = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm"); Date durationDate = null; Date end_date = null;//from w ww . j a va 2s . c o m try { durationDate = sdf.parse(task_time[i]); end_date = sdfTimeStamp.parse(end_time[i]); } catch (ParseException e) { e.printStackTrace(); } wh.setDuration(new Time(durationDate.getTime())); wh.setEnd_date(new Timestamp(end_date.getTime())); wh.setDescription(description[i]); wh.setPriority(Integer.parseInt(priority[i])); wh.setAgenda_id(personavo.getAgenda_id()); System.out.println(wh.toString()); taskManager.agregar(wh); } CreateSchedule createSchedule = new CreateSchedule(personavo); createSchedule.createSchedule(); TaskDAO taskDAO = new TaskDAO(); List<TaskVO> task_list = taskDAO.findByAgenda(personavo.getAgenda_id()); ListIterator listIterator = task_list.listIterator(); while (listIterator.hasNext()) { TaskVO task = (TaskVO) listIterator.next(); if (task.getWork_hours_id() == null) { listIterator.remove(); } } WorkHoursManager workHoursManager = new WorkHoursManager(); List<WorkHoursVO> worksHours_list = workHoursManager.consultarPorAgenda(personavo.getAgenda_id()); request.setAttribute("tasks", task_list); request.setAttribute("works", worksHours_list); RequestDispatcher rd = getServletContext().getRequestDispatcher("/schedule.jsp"); rd.forward(request, response); }
From source file:fr.paris.lutece.portal.business.user.attribute.AttributeCheckBox.java
/** * Get the data of the user fields//w ww.ja va 2 s .c o m * @param request HttpServletRequest * @param user user * @return user field data */ @Override public List<AdminUserField> getUserFieldsData(HttpServletRequest request, AdminUser user) { String[] strValues = request .getParameterValues(PARAMETER_ATTRIBUTE + CONSTANT_UNDERSCORE + getIdAttribute()); return getUserFieldsData(strValues, user); }
From source file:com.jquery.web.Request.java
private void from(HttpServletRequest servletRequest) { Enumeration<?> names = servletRequest.getParameterNames(); while (names.hasMoreElements()) { String name = (String) names.nextElement(); request.put(name, servletRequest.getParameterValues(name)); }/*from w ww . j a v a2 s . c o m*/ }
From source file:com.twinsoft.convertigo.engine.admin.services.roles.Add.java
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception { String username = request.getParameter("username"); String password = request.getParameter("password"); String[] roles = request.getParameterValues("roles"); Element root = document.getDocumentElement(); Element response = document.createElement("response"); try {/*from w ww . j av a2 s . c om*/ if (StringUtils.isBlank(username)) { throw new IllegalArgumentException("Blank username not allowed"); } if (StringUtils.isBlank(password)) { throw new IllegalArgumentException("Blank password not allowed"); } if (Engine.authenticatedSessionManager.hasUser(username)) { throw new IllegalArgumentException("User '" + username + "' already exists"); } Set<Role> set; if (roles == null) { set = Collections.emptySet(); } else { set = new HashSet<Role>(roles.length); for (String role : roles) { set.add(Role.valueOf(role)); } } Engine.authenticatedSessionManager.setUser(username, DigestUtils.md5Hex(password), set); response.setAttribute("state", "success"); response.setAttribute("message", "User '" + username + "' have been successfully declared!"); } catch (Exception e) { Engine.logAdmin.error("Error during adding the user!\n" + e.getMessage()); response.setAttribute("state", "error"); response.setAttribute("message", "Error during adding the user!\n" + e.getMessage()); } root.appendChild(response); }
From source file:com.twinsoft.convertigo.engine.admin.services.roles.Edit.java
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception { String username = request.getParameter("username"); String password = request.getParameter("password"); String[] roles = request.getParameterValues("roles"); String oldUsername = request.getParameter("oldUsername"); Element root = document.getDocumentElement(); Element response = document.createElement("response"); if (roles == null) { roles = new String[] {}; }/*from w w w .ja v a 2 s.c o m*/ try { Set<Role> set = new HashSet<Role>(roles.length); for (String role : roles) { set.add(Role.valueOf(role)); } if (StringUtils.isBlank(password)) { password = Engine.authenticatedSessionManager.getPassword(oldUsername); } else { password = DigestUtils.md5Hex(password); } if (!username.equals(oldUsername)) { if (Engine.authenticatedSessionManager.hasUser(username)) { throw new IllegalArgumentException("User '" + username + "' already exists"); } Engine.authenticatedSessionManager.setUser(username, password, set); Engine.authenticatedSessionManager.deleteUser(oldUsername); } else { Engine.authenticatedSessionManager.setUser(username, password, set); } response.setAttribute("state", "success"); response.setAttribute("message", "User '" + username + "' have been successfully edited!"); } catch (Exception e) { Engine.logAdmin.error("Error during editing the user!\n" + e.getMessage()); response.setAttribute("state", "error"); response.setAttribute("message", "Error during editing the user!\n" + e.getMessage()); } root.appendChild(response); }
From source file:org.openmrs.module.appframework.web1x.AppFrameworkHomepagePortletController.java
/** * @see org.openmrs.web.controller.PortletController#handleRequest(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) *//*w ww . j av a2 s .c o m*/ @Override public ModelAndView handleRequest(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { User currentUser = Context.getAuthenticatedUser(); String[] appParam = req.getParameterValues("app[]"); if (appParam != null) { StringBuilder data = new StringBuilder(); for (String app : appParam) { data.append(app).append(","); } // save the sort order to the user's properties log.debug("order: " + data.toString()); currentUser.setUserProperty("app_sort_order", data.toString()); try { Context.addProxyPrivilege(PrivilegeConstants.EDIT_USERS); Context.getUserService().saveUser(currentUser, null); } finally { Context.removeProxyPrivilege(PrivilegeConstants.EDIT_USERS); } } AppFrameworkService service = Context.getService(AppFrameworkService.class); List<AppDescriptor> apps = service.getAppsForUser(currentUser); if (apps.size() == 0) { // since I haven't implemented a UI for enabling apps yet, show all apps for testing: apps.addAll(service.getAllApps()); // after we've implemented enabling apps, switch to this: //apps.add(service.getAppById("legacy.openmrs")); } // if there's only one app enabled for this user, go straight to its homepage /* TODO: Figure out how to get this working. Maybe we're not allowed to redirect in a portlet? if (apps.size() == 1) { String url = apps.get(0).getHomepageUrl(); try { // this line will throw an exception if it's not a full url new URL(url); // this is a full url including protocol, so we use it verbatim return new ModelAndView(new RedirectView(url)); } catch (Exception ex) { // no protocol, so we interpret this relative to the webapp root return new ModelAndView(new RedirectView(url, true)); } } */ Map<String, Object> model = new HashMap<String, Object>(); model.put("apps", apps); return new ModelAndView("module/appframework/appFrameworkHomepage", model); }
From source file:net.duckling.ddl.web.controller.team.CreateTeamController.java
private void addTeamCreateInfo(int teamId, HttpServletRequest request) { String[] as = request.getParameterValues("teamInfo"); if (as != null) { for (String a : as) { TeamCreateInfo info = new TeamCreateInfo(); info.setTid(teamId);//from w ww . j av a 2 s .c om info.setParamKey(a); info.setParamValue(a); teamService.addTeamCreateInfo(info); } } }