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:css.controller.AdmissionGradesController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { EntityManager em = new EntityManager(); if (httpServletRequest.getMethod().equals("POST")) { String stringid[] = httpServletRequest.getParameterValues("id[]"); int id[] = new int[stringid.length]; for (int i = 0; i < stringid.length; i++) { id[i] = Integer.parseInt(stringid[i]); }// w ww. j a v a 2 s . co m String names[] = httpServletRequest.getParameterValues("name[]"); String cnps[] = httpServletRequest.getParameterValues("cnp[]"); String sgradesh[] = httpServletRequest.getParameterValues("gradeh[]"); double gradesh[] = new double[sgradesh.length]; for (int i = 0; i < sgradesh.length; i++) { gradesh[i] = Double.parseDouble(sgradesh[i]); } String sgradesb[] = httpServletRequest.getParameterValues("gradeb[]"); double gradesb[] = new double[sgradesb.length]; for (int i = 0; i < sgradesb.length; i++) { gradesb[i] = Double.parseDouble(sgradesb[i]); } String sgradesa[] = httpServletRequest.getParameterValues("gradea[]"); double gradesa[] = new double[sgradesa.length]; for (int i = 0; i < sgradesa.length; i++) { gradesa[i] = Double.parseDouble(sgradesa[i]); } for (int i = 0; i < id.length; i++) { List<Student> by = em.getBy(Student.class, new StudentFilterById(id[i])); if (!by.isEmpty()) { Student student = by.get(0); student.setNume(names[i]); student.setCNP(cnps[i]); student.setBacGrade(gradesb[i]); student.setHighSchoolGrade(gradesh[i]); student.setExamGrade(gradesa[i]); em.update(student); } } } ModelAndView model = new ModelAndView("admissiongrades"); List<Student> students = em.getAll(Student.class); model.addObject("liststud", students); return model; }
From source file:se.vgregion.pubsub.push.web.PushController.java
private void publish(HttpServletRequest request, HttpServletResponse response) throws IOException { LOG.info("Received publish request"); String[] urls = request.getParameterValues("hub.url"); if (urls != null) { try {//from w w w . j ava 2s . c o m for (String url : urls) { publish(url); } LOG.info("Published feeds successfully queued, returning 204 to publisher"); response.setStatus(204); } catch (Exception e) { LOG.warn("Exception thrown during publication", e); response.sendError(500); } } else { response.sendError(500, "Missing hub.url parameter"); } }
From source file:fr.paris.lutece.plugins.document.web.portlet.DocumentListPortletJspBean.java
/** * Set the array of id categories// w ww .j a va 2 s.c o m * @param request The http servlet request * @return The array of id categories */ private int[] setIdCategory(HttpServletRequest request) { String[] strArrayIdCategory = request.getParameterValues(PARAMETER_CATEGORY); if (strArrayIdCategory != null) { int[] nArrayIdCategory = new int[strArrayIdCategory.length]; int i = 0; for (String strIdCategory : strArrayIdCategory) { nArrayIdCategory[i++] = IntegerUtils.convert(strIdCategory); } return nArrayIdCategory; } return new int[0]; }
From source file:fr.paris.lutece.plugins.genericattributes.service.entrytype.AbstractEntryTypeCheckBox.java
/** * {@inheritDoc}// www .j a va 2 s. co m */ @Override public GenericAttributeError getResponseData(Entry entry, HttpServletRequest request, List<Response> listResponse, Locale locale) { String[] strTabIdField = request.getParameterValues(PREFIX_ATTRIBUTE + entry.getIdEntry()); List<Field> listFieldInResponse = new ArrayList<Field>(); int nIdField = -1; Field field = null; Response response; if (strTabIdField != null) { for (int cpt = 0; cpt < strTabIdField.length; cpt++) { try { nIdField = Integer.parseInt(strTabIdField[cpt]); } catch (NumberFormatException ne) { AppLogService.error(ne.getMessage(), ne); } field = GenericAttributesUtils.findFieldByIdInTheList(nIdField, entry.getFields()); if (field != null) { listFieldInResponse.add(field); } } } if (listFieldInResponse.size() != 0) { for (Field fieldInResponse : listFieldInResponse) { response = new Response(); response.setEntry(entry); response.setResponseValue(fieldInResponse.getValue()); response.setField(fieldInResponse); listResponse.add(response); } } if (entry.isMandatory()) { boolean bAllFieldEmpty = true; for (Field fieldInResponse : listFieldInResponse) { if (!fieldInResponse.getValue().equals(StringUtils.EMPTY)) { bAllFieldEmpty = false; } } if (bAllFieldEmpty) { if (StringUtils.isNotBlank(entry.getErrorMessage())) { GenericAttributeError error = new GenericAttributeError(); error.setMandatoryError(true); error.setErrorMessage(entry.getErrorMessage()); return error; } return new MandatoryError(entry, locale); } } return null; }
From source file:net.sourceforge.subsonic.controller.HLSController.java
private List<Pair<Integer, Dimension>> parseBitRates(HttpServletRequest request) throws IllegalArgumentException { List<Pair<Integer, Dimension>> result = new ArrayList<Pair<Integer, Dimension>>(); String[] bitRates = request.getParameterValues("bitRate"); if (bitRates != null) { for (String bitRate : bitRates) { result.add(parseBitRate(bitRate)); }/*from w ww.j a v a 2s . com*/ } return result; }
From source file:org.openmrs.web.controller.patient.MergePatientsFormController.java
/** * This is called prior to displaying a form for the first time. It tells Spring the * form/command object to load into the request * * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) *//*from w ww . jav a 2 s. c om*/ @Override protected Object formBackingObject(HttpServletRequest request) throws ServletException { Patient p1 = new Patient(); if (Context.isAuthenticated()) { String[] patientIds = request.getParameterValues("patientId"); if (patientIds != null && patientIds.length > 0) { String patientId = patientIds[0]; Integer pId = Integer.valueOf(patientId); p1 = Context.getPatientService().getPatient(pId); } } return p1; }
From source file:egovframework.rte.ptl.mvc.bind.CommandMapArgumentResolver.java
/** * Controller? argument? commandMap?? Map ? * HTTP request ?? ?? ? commandMap? returng. * ? ? ? Map? .//from ww w .j av a 2s. co m * * @param methodParameter - ?? ,??? * @param webRequest - web request ? * @return argument? commandMap(java.util.Map)? commandMap, <code>UNRESOLVED</code>. * @exception Exception */ public Object resolveArgument(MethodParameter methodParameter, NativeWebRequest webRequest) throws Exception { Class<?> clazz = methodParameter.getParameterType(); String paramName = methodParameter.getParameterName(); if (clazz.equals(Map.class) && paramName.equals("commandMap")) { Map<String, Object> commandMap = new HashMap<String, Object>(); HttpServletRequest request = (HttpServletRequest) webRequest.getNativeRequest(); Enumeration<?> enumeration = request.getParameterNames(); while (enumeration.hasMoreElements()) { String key = (String) enumeration.nextElement(); String[] values = request.getParameterValues(key); if (values != null) { commandMap.put(key, (values.length > 1) ? values : values[0]); } } return commandMap; } return UNRESOLVED; }
From source file:common.cms.controller.ACmsDelegate.java
/** * updates rows in database// w w w . j a v a 2 s . c o m * @param req * @param resp * @return */ public ModelAndView doMultiUpdate(HttpServletRequest req, HttpServletResponse resp) { String action = req.getParameter(ControllerConfig.ACTION_PARAM_NAME); String[] _marker = req.getParameterValues(_MARKER_PARAM); if ("multiUpdate".equals(action) && _marker != null && _marker.length > 0) { getCommonModel(req); req.setAttribute(config.getContentUrlAttribute(), config.getContentMultiupdateTemplate()); IMultiupdateBean<T, Long> command = multiUpdateService.getMultiupdateBean(_marker.length); BindingResult res = multiValidator.bindAndValidate(command, req); if (res.hasErrors()) { common.CommonAttributes.addErrorMessage("form_errors", req); req.setAttribute(res.MODEL_KEY_PREFIX + config.getContentDataAttribute(), res); } else { if (command.save(multiUpdateService) > 0) { common.CommonAttributes.addHelpMessage("operation_succeed", req); } else { common.CommonAttributes.addErrorMessage("operation_fail", req); } } if (command.isModel()) { req.setAttribute(config.getContentDataAttribute(), command.getModel()); return new ModelAndView(config.getTemplateUrl()); } else { return doView(req, resp); } } else { //set that operation fail and make doView operation common.CommonAttributes.addErrorMessage("operation_fail", req); return doView(req, resp); } //after updating values shoving all pages(doView) }
From source file:org.openmrs.web.controller.user.RoleFormController.java
/** * @see org.springframework.web.servlet.mvc.AbstractFormController#processFormSubmission(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) *///from w w w .ja va2 s . com @SuppressWarnings("unchecked") protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { Role role = (Role) obj; String[] inheritiedRoles = request.getParameterValues("inheritedRoles"); if (inheritiedRoles == null) { role.setInheritedRoles(Collections.EMPTY_SET); } String[] privileges = request.getParameterValues("privileges"); if (privileges == null) { role.setPrivileges((Set) (Collections.emptySet())); } return super.processFormSubmission(request, response, role, errors); }
From source file:com.ss.Controller.T4uArrangeSeatPlanServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* www .jav a 2 s . co m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int scheduleId = 0; try { scheduleId = Integer.parseInt(request.getParameter("scheduleId")); String[] allUSeats = request.getParameterValues("seats[]"); // Check whether the seats are occupied or unavailable in table T4U_schedule boolean occupied = false; if (allUSeats != null) { String oSeats = T4uScheduleDAO.getOSeatsById(scheduleId); for (String seat : allUSeats) if (oSeats.contains(seat)) { occupied = true; break; } } if (occupied) { // Seat occupied, need to buy again PrintWriter out = response.getWriter(); out.print("occupied"); out.flush(); } else { String uSeats = ""; if (allUSeats != null) for (String seat : allUSeats) uSeats += "'" + seat + "',"; if (T4uScheduleDAO.updateUSeatsById(scheduleId, uSeats)) { response.setHeader("Content-Type", "text/plain"); PrintWriter out = response.getWriter(); out.print("success"); out.flush(); } } } catch (NumberFormatException ex) { } }