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:jipdbs.web.processors.OpenIDLoginProcessor.java
/** * Attribute exchange example./*from ww w. j a v a 2 s. c o m*/ * * @param httpReq * @param authReq * @throws MessageException * @see <a * href="http://code.google.com/p/openid4java/wiki/AttributeExchangeHowTo">Attribute * Exchange HowTo</a> * @see <a * href="http://openid.net/specs/openid-attribute-exchange-1_0.html">OpenID * Attribute Exchange 1.0 - Final</a> */ private void addAttributeExchangeToAuthRequest(HttpServletRequest httpReq, AuthRequest authReq) throws MessageException { String[] aliases = httpReq.getParameterValues("alias"); String[] typeUris = httpReq.getParameterValues("typeUri"); String[] counts = httpReq.getParameterValues("count"); FetchRequest fetch = FetchRequest.createFetchRequest(); for (int i = 0, l = typeUris == null ? 0 : typeUris.length; i < l; i++) { String typeUri = typeUris[i]; if (StringUtils.isNotBlank(typeUri)) { String alias = aliases[i]; boolean required = httpReq.getParameter("required" + i) != null; int count = NumberUtils.toInt(counts[i], 1); fetch.addAttribute(alias, typeUri, required, count); } } authReq.addExtension(fetch); }
From source file:org.openmrs.module.tribe.web.controller.TribeListController.java
/** * /*from www .j a va2 s .c om*/ * The onSubmit function receives the form/command object that was modified * by the input form and saves it to the db * * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.validation.BindException) */ protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { log.info("onSubmit"); HttpSession httpSession = request.getSession(); String view = getFormView(); if (Context.isAuthenticated()) { String[] tribeList = request.getParameterValues("tribeId"); TribeService ts = ((TribeService) Context.getService(TribeService.class)); String action = ""; if (request.getParameter("retire") != null) action = "retire"; else if (request.getParameter("unretire") != null) action = "unretire"; String success = ""; String error = ""; MessageSourceAccessor msa = getMessageSourceAccessor(); String changed = msa.getMessage("general.changed"); String notChanged = msa.getMessage("general.cannot.change"); if (tribeList != null) { for (String t : tribeList) { try { if (action.equals("retire")) ts.retireTribe(ts.getTribe(Integer.valueOf(t)), "retired from tribe list page"); if (action.equals("unretire")) ts.unretireTribe(ts.getTribe(Integer.valueOf(t))); if (!success.equals("")) success += "<br/>"; success += t + " " + changed; } catch (APIException e) { log.warn("Error deleting tribe", e); if (!error.equals("")) error += "<br/>"; error += t + " " + notChanged; } } } view = getSuccessView(); if (!success.equals("")) httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success); if (!error.equals("")) httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error); } return new ModelAndView(new RedirectView(view)); }
From source file:com.yahoo.dba.perf.myperf.springmvc.QueryController.java
/** * If filter condition is provided, filter the results * Currently we only support single column based filtering * with req parameter rf=col&rfv=value&rfv=value.... * If provided, only result satisfying the condition (eq IN LIST) will be returned. * For now, we allow case insensitive//from w ww . j av a 2 s.co m * @param rList * @param req */ private ResultList filterResultList(ResultList rList, HttpServletRequest req) { try { String rf = req.getParameter("rf"); if (rf == null || rf.isEmpty()) return rList; int idx = rList.getColumnIndex(rf); if (idx < 0) return rList; String[] filtered_vals = req.getParameterValues("rfv"); if (filtered_vals == null || filtered_vals.length == 0) return rList; Set<String> filteredSet = new HashSet<String>(filtered_vals.length); for (String s : filtered_vals) filteredSet.add(s.toLowerCase()); ResultList newList = new ResultList(); newList.setColumnDescriptor(rList.getColumnDescriptor()); for (ResultRow row : rList.getRows()) { String v = row.getColumns().get(idx); if (v != null && filteredSet.contains(v.toLowerCase())) newList.addRow(row); } return newList; } catch (Exception ex) { logger.log(Level.INFO, "Failed to filter data", ex); } return rList; }
From source file:com.app.kmsystem.util.StringUtils.java
/** * Return an ordered map of request parameters from the given request. * * @param request the servlet request to obtain request parameters from * @return the ordered map of request parameters *///from w ww .j a v a 2 s . co m @SuppressWarnings("unchecked") public static Map<String, String> getRequestParameters(HttpServletRequest request) { TreeMap<String, String> requestParams = new TreeMap<String, String>(); Enumeration paramNames = request.getParameterNames(); while (paramNames.hasMoreElements()) { String name = paramNames.nextElement().toString(); String[] values = request.getParameterValues(name); HtmlStringBuffer valsBuffer = new HtmlStringBuffer(32); if (values.length == 1) { valsBuffer.append(values[0]); } else { for (int i = 0; i < values.length; i++) { if (i == 0) { valsBuffer.append("["); } valsBuffer.append(values[i]); if (i == values.length - 1) { valsBuffer.append("]"); } else { valsBuffer.append(","); } } } requestParams.put(name, valsBuffer.toString()); } return requestParams; }
From source file:org.openmrs.web.controller.report.PatientSearchListController.java
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); String view = getFormView();//from ww w. j a v a 2 s . c o m if (Context.isAuthenticated()) { String[] reportList = request.getParameterValues("patientSearchId"); String action = request.getParameter("action"); AdministrationService as = Context.getAdministrationService(); String success = ""; String error = ""; MessageSourceAccessor msa = getMessageSourceAccessor(); String deleted = msa.getMessage("general.deleted"); String notDeleted = msa.getMessage("general.cannot.delete"); String textPatientSearch = msa.getMessage("Patient.search"); String noneDeleted = msa.getMessage("reportingcompatibility.PatientSearch.nonedeleted"); String isInComp = msa.getMessage("reportingcompatibility.PatientSearch.isAnElementInSavedComposition"); if (msa.getMessage("reportingcompatibility.PatientSearch.delete").equals(action)) { if (reportList != null) { ReportObjectService rs = (ReportObjectService) Context.getService(ReportObjectService.class); List<AbstractReportObject> savedSearches = rs .getReportObjectsByType(OpenmrsConstants.REPORT_OBJECT_TYPE_PATIENTSEARCH); for (String p : reportList) { int compositeTest = 0; String psUsedInTheseCompositeSearches = ""; for (ReportObject ro : savedSearches) { PatientSearchReportObject psro = (PatientSearchReportObject) ro; if (psro.getPatientSearch().isComposition()) { List<Object> psList = psro.getPatientSearch().getParsedComposition(); for (Object psObj : psList) { if (psObj.getClass().getName() .contains("org.openmrs.reporting.PatientSearch")) { PatientSearch psInner = (PatientSearch) psObj; if (psInner.getSavedSearchId() != null) { if (psInner.getSavedSearchId() == Integer.valueOf(p).intValue()) { compositeTest = 1; if (!psUsedInTheseCompositeSearches.equals("")) psUsedInTheseCompositeSearches += ", "; psUsedInTheseCompositeSearches += "'" + rs.getReportObject( Integer.valueOf(psro.getReportObjectId())).getName() + "'"; } } } } } } if (compositeTest == 0) { try { as.deleteReportObject(Integer.valueOf(p)); if (!success.equals("")) success += "<br/>"; success += textPatientSearch + " " + p + " " + deleted; } catch (APIException e) { log.warn("Error deleting report object", e); if (!error.equals("")) error += "<br/>"; error += textPatientSearch + " " + p + " " + notDeleted; } } else { if (!error.equals("")) error += "<br/>"; error += textPatientSearch + " " + p + " " + notDeleted + ", " + isInComp + " " + psUsedInTheseCompositeSearches; } } } else { success += noneDeleted; } } view = getSuccessView(); if (!success.equals("")) httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success); if (!error.equals("")) httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error); } return new ModelAndView(new RedirectView(view)); }
From source file:co.id.app.sys.util.StringUtils.java
/** * Return an ordered map of request parameters from the given request. * * @param request the servlet request to obtain request parameters from * @return the ordered map of request parameters *///from w w w. j a va 2s. c o m @SuppressWarnings("rawtypes") public static Map<String, String> getRequestParameters(HttpServletRequest request) { TreeMap<String, String> requestParams = new TreeMap<String, String>(); Enumeration paramNames = request.getParameterNames(); while (paramNames.hasMoreElements()) { String name = paramNames.nextElement().toString(); String[] values = request.getParameterValues(name); HtmlStringBuffer valsBuffer = new HtmlStringBuffer(32); if (values.length == 1) { valsBuffer.append(values[0]); } else { for (int i = 0; i < values.length; i++) { if (i == 0) { valsBuffer.append("["); } valsBuffer.append(values[i]); if (i == values.length - 1) { valsBuffer.append("]"); } else { valsBuffer.append(","); } } } requestParams.put(name, valsBuffer.toString()); } return requestParams; }
From source file:net.duckling.ddl.web.controller.message.RecommendController.java
@SuppressWarnings("unchecked") private void submitRecommend(EventDispatcher eventDispatcher, HttpServletRequest request, HttpServletResponse response) {//from www .j a v a 2s. c o m VWBContext ctx = VWBContext.createContext(request, UrlPatterns.T_TEAM_HOME); String currUser = ctx.getCurrentUID(); String remark = request.getParameter("remark"); String sendType = request.getParameter("sendType"); String[] userIds = request.getParameterValues("users"); int rid = Integer.parseInt(request.getParameter("rid")); Resource res = resourceService.getResource(rid); if (res.isFile()) { eventDispatcher.sendFileRecommendEvent(ctx.getTid(), rid, res.getTitle(), currUser, res.getLastVersion(), remark, combineRecipients(userIds), sendType); } else if (res.isPage()) { eventDispatcher.sendPageRecommendEvent(ctx.getTid(), rid, res.getTitle(), currUser, res.getLastVersion(), remark, combineRecipients(userIds), sendType); } else if (res.isFolder()) { eventDispatcher.sendFolderRecommendEvent(ctx.getTid(), rid, res.getTitle(), currUser, res.getLastVersion(), remark, combineRecipients(userIds), sendType); } JSONObject object = new JSONObject(); object.put("status", "success"); object.put("itemType", res.getItemType()); JsonUtil.writeJSONObject(response, object); }
From source file:com.google.reducisaurus.servlets.BaseServlet.java
private String collectFromFormArgs(final HttpServletRequest req) throws IOException, ServletException { StringBuilder collector = new StringBuilder(); for (String urlParameterName : getSortedParameterNames(req)) { final String[] values = req.getParameterValues(urlParameterName); for (String value : values) { if (value.matches("^https?://.*")) { acquireFromRemoteUrl(req, collector, value); } else { acquireFromParameterValue(collector, value); }/*from www .j a v a 2 s.c o m*/ } } return collector.toString(); }
From source file:com.netpace.cms.sso.filter.AlfrescoOpenSSOFilter.java
private boolean isLoginRequest(HttpServletRequest request) { Enumeration parameterNames = request.getParameterNames(); while (parameterNames.hasMoreElements()) { String parameter = (String) parameterNames.nextElement(); String[] string = request.getParameterValues(parameter); for (int i = 0; i < string.length; i++) { if (string[i] != null && string[i].contains(":login")) { return true; }/*from w ww .j a v a 2s .c o m*/ } } return false; }
From source file:com.netpace.cms.sso.filter.AlfrescoOpenSSOFilter.java
private boolean isLogoutRequest(HttpServletRequest request) { Enumeration parameterNames = request.getParameterNames(); while (parameterNames.hasMoreElements()) { String parameter = (String) parameterNames.nextElement(); String[] string = request.getParameterValues(parameter); for (int i = 0; i < string.length; i++) { if (string[i] != null && string[i].contains(":logout")) { return true; }/* ww w. j ava 2 s.c o m*/ } } return false; }