List of usage examples for javax.servlet.http HttpServletRequest getParameterNames
public Enumeration<String> getParameterNames();
Enumeration
of String
objects containing the names of the parameters contained in this request. From source file:gov.nih.nci.cabig.caaers.web.validation.validator.WebControllerValidatorImpl.java
public void validate(final HttpServletRequest request, final Object command, final BindException errors) { Enumeration<String> propertyNames = request.getParameterNames(); while (propertyNames.hasMoreElements()) { String propertyName = propertyNames.nextElement(); validateProperty(propertyName, command, errors); }//from ww w . j av a2s. c o m // figure out the additional collections to validate. String additionalCollections = request.getParameter(ADDITIONAL_COLLECTIONS_PARAM); if (StringUtils.isNotEmpty(additionalCollections)) { String collectionPropertyNames[] = StringUtils.split(additionalCollections, ','); for (String collectionPropertyName : collectionPropertyNames) { validateProperty(collectionPropertyName, command, errors); } } }
From source file:de.berlios.jhelpdesk.web.ticket.TicketNewWizardController.java
private int getTarget(HttpServletRequest request, int currentPage) { if (request.getParameter("_checkLogin") != null) { return 0; }/*from w w w . j a v a 2s .co m*/ String paramPrefix = "_target"; Enumeration paramNames = request.getParameterNames(); while (paramNames.hasMoreElements()) { String paramName = (String) paramNames.nextElement(); if (paramName.startsWith(paramPrefix)) { for (int i = 0; i < SUBMIT_IMAGE_SUFFIXES.length; i++) { String suffix = SUBMIT_IMAGE_SUFFIXES[i]; if (paramName.endsWith(suffix)) { paramName = paramName.substring(0, paramName.length() - suffix.length()); } } return Integer.parseInt(paramName.substring(paramPrefix.length())); } } return currentPage; }
From source file:com.fantasia.snakerflow.web.FlowController.java
@RequestMapping(value = "process") public String process(HttpServletRequest request) { Map<String, Object> params = new HashMap<String, Object>(); Enumeration<String> paraNames = request.getParameterNames(); while (paraNames.hasMoreElements()) { String element = paraNames.nextElement(); int index = element.indexOf("_"); String paraValue = request.getParameter(element); if (index == -1) { params.put(element, paraValue); } else {//from ww w.j a v a 2 s . com char type = element.charAt(0); String name = element.substring(index + 1); Object value = null; switch (type) { case 'S': value = paraValue; break; case 'I': value = ConvertUtils.convert(paraValue, Integer.class); break; case 'L': value = ConvertUtils.convert(paraValue, Long.class); break; case 'B': value = ConvertUtils.convert(paraValue, Boolean.class); break; case 'D': value = ConvertUtils.convert(paraValue, Date.class); break; case 'N': value = ConvertUtils.convert(paraValue, Double.class); break; default: value = paraValue; break; } params.put(name, value); } } String processId = request.getParameter("processId"); String orderId = request.getParameter("orderId"); String taskId = request.getParameter("taskId"); String nextOperator = request.getParameter(""); kpiWorkFlow.process(request); if (StringUtils.isEmpty(orderId) && StringUtils.isEmpty(taskId)) { facets.startAndExecute(processId, DbcContext.getUser().getUserName(), params); } else { String methodStr = request.getParameter("method"); int method; try { method = Integer.parseInt(methodStr); } catch (Exception e) { method = 0; } switch (method) { case 0:// facets.execute(taskId, DbcContext.getUser().getUserName(), params); break; case -1://?? facets.executeAndJump(taskId, DbcContext.getUser().getUserName(), params, request.getParameter("nodeName")); break; case 1:// if (StringUtils.isNotEmpty(nextOperator)) { facets.transferMajor(taskId, DbcContext.getUser().getUserName(), nextOperator.split(",")); } break; case 2://?? if (StringUtils.isNotEmpty(nextOperator)) { facets.transferAidant(taskId, DbcContext.getUser().getUserName(), nextOperator.split(",")); } break; default: facets.execute(taskId, DbcContext.getUser().getUserName(), params); break; } } String ccOperator = request.getParameter("ccoperator"); if (StringUtils.isNotEmpty(ccOperator)) { facets.getEngine().order().createCCOrder(orderId, ccOperator.split(",")); } return "redirect:/snaker/task/active"; }
From source file:edu.harvard.i2b2.fhirserver.ws.OAuth2TokenEndpoint.java
@POST @Consumes("application/x-www-form-urlencoded") @Produces("application/json") public Response authorize(@Context HttpServletRequest request) throws OAuthSystemException, IOException { try {//from w w w .jav a2 s . c o m logger.info("got url:" + request.getRequestURL()); Enumeration<String> kl = request.getParameterNames(); while (kl.hasMoreElements()) { String k = kl.nextElement(); logger.debug(k + "->" + request.getParameter(k)); } OAuthTokenRequest oauthRequest = new OAuthTokenRequest(request); OAuthIssuer oauthIssuerImpl = new OAuthIssuerImpl(new MD5Generator()); // find if AuthToken was issued, from db String authCode = oauthRequest.getCode(); AuthToken authToken = authTokenBean.find(authCode); if (authToken == null) { logger.debug("authToken is not found"); return buildBadAuthCodeResponse(); } logger.debug("authToken is " + authToken.toString()); // check if clientid is valid if (!checkClientId(oauthRequest.getClientId())) { return buildInvalidClientIdResponse(); } // check if client_secret is valid if (!checkClientSecret(oauthRequest.getClientSecret())) { return buildInvalidClientSecretResponse(); } // do checking for different grant types if (oauthRequest.getParam(OAuth.OAUTH_GRANT_TYPE).equals(GrantType.AUTHORIZATION_CODE.toString())) { if (!checkAuthCode(authToken, oauthRequest.getParam(OAuth.OAUTH_CODE))) { return buildBadAuthCodeResponse(); } } else if (oauthRequest.getParam(OAuth.OAUTH_GRANT_TYPE).equals(GrantType.PASSWORD.toString())) { if (!checkUserPass(oauthRequest.getUsername(), oauthRequest.getPassword(), authToken)) { return buildInvalidUserPassResponse(); } } else if (oauthRequest.getParam(OAuth.OAUTH_GRANT_TYPE).equals(GrantType.REFRESH_TOKEN.toString())) { // refresh token is not supported in this implementation // buildInvalidUserPassResponse(); //buildAccessTokenNotSupportedResponse(); } final String accessTokenString = oauthIssuerImpl.accessToken(); // database.addToken(accessToken); String resourceUserId = authToken.getResourceUserId(); String i2b2Token = authToken.getI2b2Token(); String i2b2Project = authToken.getI2b2Project(); String clientId = authToken.getClientId(); String scope = authToken.getScope(); accessTokenBean.createAccessTokenAndDeleteAuthToken(authCode, accessTokenString, resourceUserId, i2b2Token, i2b2Project, clientId, scope); OAuthResponse response = OAuthASResponse.tokenResponse(HttpServletResponse.SC_OK) .setAccessToken(accessTokenString).setExpiresIn("3600").buildJSONMessage(); logger.info("returning res:" + response.getBody()); return Response.status(response.getResponseStatus()).entity(response.getBody()).build(); } catch (OAuthProblemException e) { logger.error(e.getMessage(), e); OAuthResponse res = OAuthASResponse.errorResponse(HttpServletResponse.SC_BAD_REQUEST).error(e) .buildJSONMessage(); return Response.status(res.getResponseStatus()).entity(res.getBody()).build(); } }
From source file:com.epimorphics.appbase.templates.Lib.java
/** * Paging helper. Generate request for a numbered page */// w w w . ja v a 2s.c o m public String pageURL(HttpServletRequest request, int page) { String url = request.getRequestURI(); Enumeration<String> names = request.getParameterNames(); boolean started = false; while (names.hasMoreElements()) { if (started) { url += "&"; } else { url += "?"; started = true; } String param = names.nextElement(); if (!param.equals(PAGE_PARAM)) { url += param + "=" + pathEncode(request.getParameter(param)); } } if (started) { url += "&"; } else { url += "?"; } url += PAGE_PARAM + "=" + page; return url; }
From source file:de.thorstenberger.taskmodel.view.SavePageAction.java
private List<SubmitData> getSubmitData(final HttpServletRequest request, final List<SubTasklet> subtasklets) throws ParsingException { try {//from w ww . j a v a2s . c o m final Enumeration varNames = request.getParameterNames(); // wir erwarten Variablen zu den entsprechenden Tasks // wenn das nicht bereinstimmt, dann ArrayIndexOutOfBoundsException final Map[] taskVarMaps = new Map[subtasklets.size()]; for (int i = 0; i < taskVarMaps.length; i++) { taskVarMaps[i] = new HashMap(); } while (varNames.hasMoreElements()) { final String varName = (String) varNames.nextElement(); if (varName.startsWith("task[")) { final int relativeTaskNo = getRelativeTaskNo(varName); if (relativeTaskNo >= 0) { taskVarMaps[relativeTaskNo].put(varName, request.getParameter(varName)); } } } final List<SubmitData> ret = new ArrayList<SubmitData>(subtasklets.size()); for (int i = 0; i < subtasklets.size(); i++) { ret.add(i, TaskModelServices.getInstance().getSubTaskView(subtasklets.get(i)) .getSubmitData(taskVarMaps[i])); } return ret; } catch (final ArrayIndexOutOfBoundsException e) { throw new ParsingException(e); } }
From source file:cn.loveapple.service.interceptor.front.core.ResponseInterceptor.java
/** * /* w w w . j a v a2 s . com*/ * {@inheritDoc} */ @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (log.isDebugEnabled()) { log.debug("Request URI:" + request.getRequestURI()); StringBuilder paramStr = new StringBuilder(1024); for (@SuppressWarnings("unchecked") Enumeration e = request.getParameterNames(); e.hasMoreElements();) { String name = (String) e.nextElement(); paramStr.append("["); paramStr.append(name); paramStr.append("="); paramStr.append(request.getParameter(name)); paramStr.append("]"); } log.debug("Form Parameters:" + paramStr); } return true; }
From source file:CPD4414Assign3.ProductServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { try (PrintWriter out = response.getWriter()) { Connection conn = getConnection(); Statement stmt = conn.createStatement(); if (!request.getParameterNames().hasMoreElements()) { out.println(getResults("SELECT * FROM product")); } else {/*from www . j a va 2 s. c om*/ if (request.getParameter("productID") == null) { out.println(getResults("SELECT * FROM product ORDER BY productID DESC LIMIT 1")); } else { int id = Integer.parseInt(request.getParameter("productID")); out.println(getResults("SELECT * FROM product WHERE productID = ?", String.valueOf(id))); } } } catch (SQLException ex) { Logger.getLogger(ProductServlet.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:net.sf.ginp.GinpServlet.java
/** * Extract Command Parameter NAmes and Values from the HTTP Request. * *@param req HTTP Request.// ww w. j a v a 2 s . c om *@return A vector of Command Parameters. */ final Vector extractParameters(final HttpServletRequest req) { Vector params = new Vector(); Enumeration names = req.getParameterNames(); while (names.hasMoreElements()) { String name = (String) names.nextElement(); params.add(new CommandParameter(name, req.getParameter(name))); log.debug("new CommandParameter(" + name + ", " + req.getParameter(name) + ")"); } ServletRequestContext reqContext = new ServletRequestContext(req); if (FileUpload.isMultipartContent(reqContext)) { try { // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(); // Set upload parameters //upload.setSizeThreshold(yourMaxMemorySize); //upload.setSizeMax(yourMaxRequestSize); //upload.setRepositoryPath(yourTempDirectory); // Parse the request List items = upload.parseRequest(req); Iterator iter = items.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (item.isFormField()) { params.add(new CommandParameter(item.getFieldName(), item.getString())); } else { CommandParameter fileParam = new CommandParameter(item.getFieldName(), item.getName()); fileParam.setObject(item.getInputStream()); params.add(fileParam); } } } catch (Exception ex) { log.error("extract parameters error getting input stream" + " from file upload", ex); } } return params; }