List of usage examples for javax.servlet ServletRequest getParameter
public String getParameter(String name);
String
, or null
if the parameter does not exist. From source file:org.kuali.rice.krad.web.bind.UifServletRequestDataBinder.java
/** * Attempts to get a view instance by looking for a view type name in the request or the form and querying * that view type with the request parameters * * @param request request instance to pull parameters from * @param form form instance to pull values from * @return View instance if found or null *//*from w w w . ja va 2 s .c o m*/ protected View getViewByType(ServletRequest request, UifFormBase form) { View view = null; String viewTypeName = request.getParameter(UifParameters.VIEW_TYPE_NAME); ViewType viewType = StringUtils.isBlank(viewTypeName) ? form.getViewTypeName() : ViewType.valueOf(viewTypeName); if (viewType != null) { Map<String, String> parameterMap = KRADUtils.translateRequestParameterMap(request.getParameterMap()); view = getViewService().getViewByType(viewType, parameterMap); } return view; }
From source file:pt.webdetails.cdc.plugin.CdcContentGenerator.java
/** * Set up parameters to render a dashboard from the presentation layer * * @param dashboardName//from w w w . jav a 2 s . com * @return */ private Map<String, Object> getRenderRequestParameters(String dashboardName) { Map<String, Object> params = new HashMap<String, Object>(); params.put("solution", "system"); params.put("path", UI_PATH); params.put("file", dashboardName); params.put("bypassCache", "true"); params.put("absolute", "true"); params.put("inferScheme", "true"); params.put("root", getRoot()); //add request parameters ServletRequest request = getRequest(); @SuppressWarnings("unchecked") //should always be String Enumeration<String> originalParams = request.getParameterNames(); // Iterate and put the values there while (originalParams.hasMoreElements()) { String originalParam = originalParams.nextElement(); params.put(originalParam, request.getParameter(originalParam)); } return params; }
From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration.java
/** * The editKey can be a HTTP query parameter or it can be a request attribute. *///from w w w. ja v a 2s.c om public static String getEditKey(ServletRequest request) { String key = null; if (request instanceof HttpServletRequest) { HttpServletRequest hsreq = (HttpServletRequest) request; boolean isMultipart = ServletFileUpload.isMultipartContent(hsreq); if (isMultipart) { //multipart parsing will consume all request parameters so //the editKey needs to be stashed in the request attributes. key = (String) request.getAttribute("editKey"); if (key == null) { // handle the cancel button where nothing is really uploaded key = request.getParameter("editKey"); } } else { key = (String) request.getAttribute("editKey"); if (key != null) { return key; } else { key = request.getParameter("editKey"); } } } if (key != null && key.trim().length() > 0) { return key; } else { log.debug("cannnot find editKey in request query parameters or from request"); return null; } }
From source file:org.ajax4jsf.webapp.BaseFilter.java
/** * @param request//from w ww . j a v a 2 s . com * @return */ protected boolean isAjaxRequest(ServletRequest request) { try { return null != request.getParameter(AjaxContainerRenderer.AJAX_PARAMETER_NAME); } catch (Exception e) { // OCJ 10 - throw exception for static resources. return false; } }
From source file:gov.nih.nci.cabig.caaers.web.ae.CaptureAdverseEventController.java
/** * Returns the value associated with the <code>attributeName</code>, if present in * HttpRequest parameter, if not available, will check in HttpRequest attribute map. *///from ww w.j ava 2 s . co m protected Object findInRequest(final ServletRequest request, final String attributName) { Object attr = request.getParameter(attributName); if (attr == null) { attr = request.getAttribute(attributName); } return attr; }
From source file:au.org.paperminer.main.UserFilter.java
/** * Set values and update persistent user store. If the email has changed, reset status * and issue verification email if requested. * @param id User ID// w w w . j av a2s.c om * @param req * @param resp */ private void resetUserData(String id, ServletRequest req, ServletResponse resp) { UserHelper helper = new UserHelper(id); if (helper.isKnownUser()) { String email = req.getParameter("em"); String troveKey = req.getParameter("tk"); String verify = req.getParameter("vfy"); m_logger.debug(email + "," + troveKey + "," + verify); if (!isValidEmailAddress(email)) { req.setAttribute(PaperMinerConstants.ERROR_PAGE, "e101"); } else if (!isValidTroveKey(troveKey)) { req.setAttribute(PaperMinerConstants.ERROR_PAGE, "e102"); } else { boolean emailChanged = !email.equals(helper.get(UserHelper.EMAIL)); if (email.equals(helper.get(UserHelper.EMAIL)) && troveKey.equals(helper.get(UserHelper.TROVE_KEY))) { m_logger.debug("update ignored, no change: " + email + "," + troveKey + "," + verify); } else { String status = emailChanged ? Integer.toString(PaperMinerConstants.USER_CREATED) : helper.get(UserHelper.STATUS); helper.set(UserHelper.EMAIL, email); helper.set(UserHelper.STATUS, status); helper.set(UserHelper.TROVE_KEY, troveKey); m_logger.debug("Updating user " + id + " to " + email + "/" + troveKey + " status " + status); try { helper.update(); } catch (PaperMinerException ex) { m_logger.error("error updating user", ex); req.setAttribute(PaperMinerConstants.ERROR_PAGE, "e108"); } } //if ((emailChanged || helper.get(UserHelper.STATUS).equals(PaperMinerConstants.USER_CREATED)) && (verify != null) && verify.equals('y')) { if ((verify != null) && verify.equals("y")) { sendVerificationEmail(id, email, req); } } } }
From source file:edu.umich.ctools.sectionsUtilityTool.SectionUtilityToolFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { M_log.debug("doFilter: Called"); HttpServletRequest useRequest = (HttpServletRequest) request; HttpServletResponse useResponse = (HttpServletResponse) response; if (BASIC_LTI_LAUNCH_REQUEST.equals(request.getParameter(LTI_MESSAGE_TYPE))) { M_log.debug("new launch so invalidate any existing session"); if (useRequest.getSession() != null) { M_log.info("session id to invalidate: " + useRequest.getSession().getId()); useRequest.getSession().invalidate(); }/*from ww w . ja va2 s . co m*/ } HttpSession session = useRequest.getSession(true); M_log.debug("session id: " + session.getId()); //Launch type for for the LTI part will be different from the launch //type for SC because LTI will only be launched within LMS and SC can //be launched from a browser setLaunchType(request, session); M_log.debug("Launch Type: " + session.getAttribute(LAUNCH_TYPE)); M_log.debug("Path Info: " + useRequest.getPathInfo()); if (session.getAttribute(LAUNCH_TYPE).equals("lti")) { if (useRequest.getPathInfo() != null && useRequest.getPathInfo().equals(SC_PAGE)) { useRequest.getSession().invalidate(); useResponse.sendError(403); return; } chain.doFilter(useRequest, response); } else if (session.getAttribute(LAUNCH_TYPE).equals("sc")) { if (!checkForAuthorization(useRequest)) { useResponse.sendError(403); return; } chain.doFilter(useRequest, response); } }
From source file:org.opencms.search.solr.spellchecking.CmsSolrSpellchecker.java
/** * Parse parameters from this request using HTTP. * * @param req The ServletRequest containing all request parameters. * @param cms The OpenCms object./*w w w . j a v a 2 s. co m*/ * @return CmsSpellcheckingRequest object that contains parsed parameters. */ private CmsSpellcheckingRequest parseHttpRequest(final ServletRequest req, final CmsObject cms) { if ((null != cms) && !cms.getRequestContext().getCurrentUser().isGuestUser()) { if (null != req.getParameter(HTTP_PARAMETER_CHECKREBUILD)) { if (CmsSpellcheckDictionaryIndexer.updatingIndexNecessesary(cms)) { parseAndAddDictionaries(cms); } } if (null != req.getParameter(HTTP_PARAMTER_REBUILD)) { parseAndAddDictionaries(cms); } } final String q = req.getParameter(HTTP_PARAMETER_WORDS); if (null == q) { LOG.debug("Invalid HTTP request: No parameter \"" + HTTP_PARAMETER_WORDS + "\" defined. "); return null; } final StringTokenizer st = new StringTokenizer(q); final List<String> wordsToCheck = new ArrayList<String>(); while (st.hasMoreTokens()) { final String word = st.nextToken(); wordsToCheck.add(word); if (Character.isUpperCase(word.codePointAt(0))) { wordsToCheck.add(word.toLowerCase()); } } final String[] w = wordsToCheck.toArray(new String[wordsToCheck.size()]); final String dict = req.getParameter(HTTP_PARAMETER_LANG) == null ? LANG_DEFAULT : req.getParameter(HTTP_PARAMETER_LANG); return new CmsSpellcheckingRequest(w, dict); }
From source file:com.spshop.web.ShoppingController.java
private String retriveProductId(ServletRequest request) { String productId = null;//w ww .ja v a 2 s . c o m try { productId = request.getParameter(PRODUCT_ID); } catch (NumberFormatException e) { //e.printStackTrace(); } return productId; }
From source file:com.iflytek.edu.cloud.frame.web.filter.CheckOpenServiceFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletResponse httpServletResponse = (HttpServletResponse) response; HttpServletRequest httpServletRequest = (HttpServletRequest) request; MainError mainError = null;/*from w ww .j a va2 s.c om*/ Locale locale = getLocale(request); String format = request.getParameter(Constants.SYS_PARAM_KEY_FORMAT); if (!StringUtils.hasText(format)) { format = Constants.DATA_FORMAT_XML; } request.setAttribute(Constants.SYS_PARAM_KEY_LOCALE, locale); request.setAttribute(Constants.SYS_PARAM_KEY_FORMAT, format); String appkey = request.getParameter(Constants.SYS_PARAM_KEY_APPKEY); if (!StringUtils.hasText(appkey)) { mainError = MainErrors.getError(MainErrorType.MISSING_APPKEY, locale); } else { RestContextHolder.getContext().addParam(Constants.SYS_PARAM_KEY_APPKEY, appkey); } //??GET, POST if (mainError == null) { String httpMethod = httpServletRequest.getMethod(); if (!Constants.HTTP_METHOD_GET.equals(httpMethod) && !Constants.HTTP_METHOD_POST.equals(httpMethod)) { mainError = MainErrors.getError(MainErrorType.HTTP_ACTION_NOT_ALLOWED, locale); } } //service method?version? if (mainError == null) { String method = request.getParameter(Constants.SYS_PARAM_KEY_METHOD); if (!StringUtils.hasText(method)) { //method? mainError = MainErrors.getError(MainErrorType.MISSING_METHOD, locale); } else { if (methodVersionMap.containsKey(method)) { String version = request.getParameter(Constants.SYS_PARAM_KEY_VERSION); if (!StringUtils.hasText(version)) { //? mainError = MainErrors.getError(MainErrorType.MISSING_VERSION, locale); } else { if (!methodVersionMap.get(method).contains(version)) { //?? mainError = MainErrors.getError(MainErrorType.UNSUPPORTED_VERSION, locale); } } } else { //method? mainError = MainErrors.getError(MainErrorType.INVALID_METHOD, locale); } } } //access_token? if (mainError == null) { if (EnvUtil.oauthEnabled()) { String accessToken = request.getParameter(Constants.SYS_PARAM_KEY_ACCESS_TOKEN); if (!checkHeaderToken(httpServletRequest) && !StringUtils.hasText(accessToken)) { mainError = MainErrors.getError(MainErrorType.MISSING_ACCESS_TOKEN, locale); } } } //jsonp String callback = httpServletRequest.getParameter(Constants.SYS_PARAM_KEY_CALLBACK); if (StringUtils.hasText(callback)) RestContextHolder.getContext().addParam(Constants.SYS_PARAM_KEY_CALLBACK, callback); if (mainError != null) { request.setAttribute(Constants.MAIN_ERROR_CODE, mainError.getCode()); httpServletResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST); messageConverter.convertData(httpServletRequest, httpServletResponse, mainError); } else { chain.doFilter(request, response); } requestLogging.recoredLog(httpServletRequest, httpServletResponse); RestContextHolder.clearContext(); }