Example usage for javax.servlet ServletRequest getParameter

List of usage examples for javax.servlet ServletRequest getParameter

Introduction

In this page you can find the example usage for javax.servlet ServletRequest getParameter.

Prototype

public String getParameter(String name);

Source Link

Document

Returns the value of a request parameter as a String, or null if the parameter does not exist.

Usage

From source file:com.gamewin.weixin.web.task.ManageTaskController.java

@RequiresRoles("admin")
@RequestMapping(value = "update", method = RequestMethod.POST)
public String update(@Valid @ModelAttribute("manageTask") ManageTask manageTask,
        RedirectAttributes redirectAttributes, ServletRequest request) {
    String startDateStr = request.getParameter("startDateStr");
    String endDateStr = request.getParameter("endDateStr");
    // ?//from  w w w  .ja  va  2 s.  c  o  m

    ManageTask manageTaskOld = manageTaskService.getManageTask(manageTask.getId());
    manageTaskOld.setState("N");
    manageTaskService.saveManageTask(manageTaskOld);
    // ??
    manageTaskService.invalidAllQRCode(manageTaskOld.getId());

    try {
        User user = new User(getCurrentUserId());
        manageTask.setId(null);
        manageTask.setTitle(manageTask.getTitle() + "()");
        manageTask.setUser(user);
        manageTask.setIsdelete(0);
        manageTask.setState("Y");
        manageTask.setCreateDate(new Date());
        manageTask.setStartDate(DateUtils.parseDate(startDateStr, "yyyy-MM-dd"));
        manageTask.setEndDate(DateUtils.parseDate(endDateStr, "yyyy-MM-dd"));
        manageTaskService.saveManageTask(manageTask);

        // 
        // manageTaskService.deleteViewRangeUserByTask(manageTask.getId());

        if ("SELECT".equals(manageTask.getViewrangeType())) {
            // ??
            String viewrangeUsers = request.getParameter("viewrangeUsers");
            if (!StringUtils.isEmpty(viewrangeUsers)) {
                String[] viewrangeUserArray = viewrangeUsers.split(",");
                for (int i = 0; i < viewrangeUserArray.length; i++) {
                    Long userId = Long.parseLong(viewrangeUserArray[i]);
                    User user_vr = new User(userId);
                    ViewRange vr = new ViewRange();
                    vr.setCreateDate(new Date());
                    vr.setIsdelete(0);
                    vr.setTask(manageTask);
                    vr.setUser(user_vr);
                    manageTaskService.saveViewRange(vr);

                    User msUser = accountService.getUser(userId);
                    if (!StringUtils.isEmpty(msUser.getWeixinOpenid())) {
                        String AccessToken = manageTaskService.getAccessToken();
                        MobileHttpClient.sendWinXinMessage(AccessToken, msUser.getWeixinOpenid(),
                                ",??'" + manageTaskOld.getTitle()
                                        + "',??!",
                                "?", MobileContants.YM);
                    }
                }
            }
        }

        redirectAttributes.addFlashAttribute("message",
                "?,?");
    } catch (Exception e) {
        e.printStackTrace();
        redirectAttributes.addFlashAttribute("message", "");
        return "redirect:/manageTask/";
    }
    return "redirect:/manageTask/";
}

From source file:org.wso2.carbon.identity.captcha.connector.recaptcha.AbstractReCaptchaConnector.java

@Override
public boolean verifyCaptcha(ServletRequest servletRequest, ServletResponse servletResponse)
        throws CaptchaException {

    if (((HttpServletRequest) servletRequest).getMethod().equalsIgnoreCase("GET")) {
        throw new CaptchaClientException("reCaptcha response must send in a POST request.");
    }//from   w  w w . j  av a  2  s  .  c o  m

    String reCaptchaResponse = servletRequest.getParameter("g-recaptcha-response");
    if (StringUtils.isBlank(reCaptchaResponse)) {
        throw new CaptchaClientException("reCaptcha response is not available in the request.");
    }

    return CaptchaUtil.isValidCaptcha(reCaptchaResponse);
}

From source file:fr.putnami.pwt.plugin.ajaxbot.filter.AjaxPageFilter.java

@Override
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
        throws IOException, ServletException {
    HttpServletRequest request = (HttpServletRequest) req;

    if (HttpMethod.GET.toString().equals(request.getMethod())
            && req.getParameter(QUERY_PARAM_ESCAPED_FRAGMENT) != null) {
        ByteStreams.copy(this.getHtmlStream(request), resp.getOutputStream());
    } else {/*  ww  w.  ja  v  a  2 s. c o m*/
        chain.doFilter(req, resp);
    }
}

From source file:org.ng200.openolympus.controller.auth.RecaptchaAuthenticationFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    if (!this.LOGIN_REQUEST_MATCHER.matches((HttpServletRequest) request)) {
        chain.doFilter(request, response);
        return;// w  w w  .  jav  a 2  s .c  o  m
    }
    final String recaptchaResponse = request.getParameter("recaptchaResponse");

    List<String> recaptchaErrors;
    try {
        recaptchaErrors = this.captchaService.checkCaptcha(recaptchaResponse);
    } catch (final URISyntaxException e) {
        throw new GeneralNestedRuntimeException("Couldn't access Recaptcha servers: ", e);
    }

    if (recaptchaErrors != null && !recaptchaErrors.isEmpty()) {
        this.recaptchaError(request, response, recaptchaErrors);
        return;
    }

    chain.doFilter(request, response);
}

From source file:org.sakaiproject.nakamura.http.i18n.I18nFilter.java

/**
 * {@inheritDoc}//  w  w  w  .  j a va  2  s .c om
 *
 * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
 *      javax.servlet.ServletResponse, javax.servlet.FilterChain)
 */
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {

    if ("true".equals(request.getParameter("raw"))) {
        chain.doFilter(request, response);
        return;
    }

    // get path info
    SlingHttpServletRequest srequest = (SlingHttpServletRequest) request;
    HttpServletResponse httpResponse = (HttpServletResponse) response;
    String path = srequest.getPathInfo();

    // check that the path is something we should filter.
    boolean filter = false;
    if ((path.startsWith("/dev/") || path.startsWith("/devwidgets/")) && path.endsWith(".html")) {
        httpResponse = new CapturingHttpServletResponse(httpResponse);
        filter = true;
    }

    // allow the chain to process so we can capture the response
    chain.doFilter(request, httpResponse);

    // if the path was set to be filtered, get the output and filter it
    // otherwise the response isn't wrapped and doesn't require us to intervene
    if (filter) {
        String output = httpResponse.toString();
        if (!StringUtils.isBlank(output)) {
            long start = System.currentTimeMillis();

            writeFilteredResponse(srequest, response, output);

            long end = System.currentTimeMillis();
            logger.debug("Filtered {} in {}ms", path, (end - start));
        }
    }
}

From source file:com.gamewin.weixin.web.account.RegisterController.java

@RequestMapping(method = RequestMethod.POST)
public String register(@Valid User user, RedirectAttributes redirectAttributes, ServletRequest request) {
    user.setIsdelete(0);/*from  ww w . ja v  a2 s  . c om*/

    String upuserId = request.getParameter("upuserId");
    if (!StringUtils.isEmpty(upuserId)) {
        User upuser = accountService.getUser(Long.parseLong(upuserId));
        if (upuser != null
                && ("TwoAdmin".equals(upuser.getRoles()) || "ThreeAdmin".equals(upuser.getRoles()))) {
            String activationCode = request.getParameter("activationCode");
            if (!StringUtils.isEmpty(activationCode)) {
                List<ActivationCode> codeList = activationCodeService.getActivationCodeByCode(activationCode);
                if (codeList != null && codeList.size() > 0) {
                    ActivationCode code = codeList.get(0);
                    if ("disabled".equals(code.getStatus())) {
                        redirectAttributes.addFlashAttribute("message", ",?");
                        return "redirect:/register";
                    }
                    if (!"N".equals(code.getStatus())) {
                        redirectAttributes.addFlashAttribute("message", ",?");
                        return "redirect:/register";
                    } else if (!upuserId.equals(code.getUser().getId())) {
                        redirectAttributes.addFlashAttribute("message",
                                ",???");
                        return "redirect:/register";
                    } else if (!"CREATEUSER".equals(code.getActivationCodeType())) {
                        redirectAttributes.addFlashAttribute("message", ",??");
                        return "redirect:/register";
                    } else {
                        user.setUpuser(upuser);
                        user.setStatus("enabled");
                        accountService.registerUser(user);

                        /*
                         * code.setStatus("Y"); code.setActivationDate(new
                         * Date()); code.setActivationUser(user);
                         * activationCodeService.saveActivationCode(code);
                         */

                        redirectAttributes.addFlashAttribute("message", "?.");
                        return "redirect:/login";
                    }

                } else {
                    redirectAttributes.addFlashAttribute("message", ",??");
                    return "redirect:/register";
                }

            } else {
                user.setUpuser(upuser);
                user.setStatus("Audit");
                accountService.registerUser(user);
                redirectAttributes.addFlashAttribute("message", "??,.");
                return "redirect:/login";
            }

        } else {
            user.setStatus("Audit");
            accountService.registerUser(user);
            redirectAttributes.addFlashAttribute("message", "??,.");
            return "redirect:/login";
        }
    } else {
        user.setStatus("Audit");
        accountService.registerUser(user);
        redirectAttributes.addFlashAttribute("message", "??,.");
        return "redirect:/login";
    }

}

From source file:org.alfresco.web.app.servlet.LanguageCookieFilter.java

public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
        throws IOException, ServletException {

    String lang = null;//ww  w.j  a va 2s  . c om
    // check if parameter "mllang" is there
    String mlLang = servletRequest.getParameter("mllang");
    String mlLangContent = servletRequest.getParameter("mllangcontent");
    dumpCookies(servletRequest);
    String locale = positionCookie(servletRequest, servletResponse, mlLang, MLPREF, false);

    if (mlLangContent != null && mlLangContent.equals("reset")) {
        Cookie mlpref = new Cookie(MLPREFCONTENT, ""); // Set expiry date after 24 Hrs forboth the cookies. 
        mlpref.setMaxAge(0);
        ((HttpServletResponse) servletResponse).addCookie(mlpref);
        I18NUtil.setContentLocale(null);
    } else {
        positionCookie(servletRequest, servletResponse, mlLangContent, MLPREFCONTENT, true);
    }
    // create the NullFakeHeaderRequest so WebscriptServlet does not modify
    // the request again.
    // recuperate the lang
    if (locale == null) {
        // default it to "en"
        locale = "en";
    }
    NullFakeHeaderRequest request = new NullFakeHeaderRequest((HttpServletRequest) servletRequest, locale);
    filterChain.doFilter(request, servletResponse);

    return;
}

From source file:com.google.code.lightssh.project.security.shiro.MySecondaryLicensePermissionsAuthorizationFilter.java

/**
 * ??//from   ww  w  .j a v a 2 s. c o m
 */
@Override
public boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue)
        throws IOException {

    Subject subject = getSubject(request, response);
    String[] perms = (String[]) mappedValue;

    boolean isPermitted = true;
    String targetUrl = request.getParameter("targetUrl");
    if (targetUrl == null) {
        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
        targetUrl = httpServletRequest.getRequestURI().substring(httpServletRequest.getContextPath().length());
    }
    AuthorizedResource authResource = authorizedResourceManager.getWithRegexp("/" + targetUrl);
    if (authResource != null) {
        isPermitted = checkTempAuth((HttpServletRequest) request, perms);
    } else {
        if (perms != null && perms.length > 0) {
            //               boolean tempAuthed = tempAuthService.authorize(perms,request);
            if (perms.length == 1) {
                if (!subject.isPermitted(perms[0])) {
                    isPermitted = false;
                }
            } else {
                if (!subject.isPermittedAll(perms)) {
                    isPermitted = false;
                }
            }
        }
    }
    return isPermitted;
}

From source file:com.delmar.core.web.filter.ExportFilter.java

/**
 * {@inheritDoc}//  w  w w.  j  a v a2 s. co m
 */
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
        throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) servletRequest;
    request.setCharacterEncoding(endcoding);
    if (servletRequest.getParameter(TableTagParameters.PARAMETER_EXPORTING) == null) {
        if (log.isDebugEnabled()) {
            log.debug(Messages.getString("ResponseOverrideFilter.parameternotfound")); //$NON-NLS-1$
        }
        // don't filter!
        filterChain.doFilter(servletRequest, servletResponse);
        return;
    }

    BufferedResponseWrapper wrapper = new BufferedResponseWrapper13Impl((HttpServletResponse) servletResponse);

    Map contentBean = new HashMap(4);
    if (buffer) {
        contentBean.put(TableTagParameters.BEAN_BUFFER, Boolean.TRUE);
    }
    request.setAttribute(TableTag.FILTER_CONTENT_OVERRIDE_BODY, contentBean);

    filterChain.doFilter(request, wrapper);

    ExportDelegate.writeExport((HttpServletResponse) servletResponse, servletRequest, wrapper);
}

From source file:com.netsteadfast.greenstep.publish.impl.SystemMessagePublishServiceImpl.java

@Override
public WebMessagePublishBaseObj execute(SysMsgNoticeConfigVO config, ServletRequest request)
        throws ServiceException, Exception {
    this.request = request;
    WebMessagePublishBaseObj publishObj = new WebMessagePublishBaseObj();
    String account = request.getParameter("account");
    String refreshUUID = StringUtils.defaultString(request.getParameter("refreshUUID")).trim();
    String sessionId = ((HttpServletRequest) request).getSession().getId();
    AccountVO accountObj = (AccountVO) UserAccountHttpSessionSupport.get((HttpServletRequest) request);
    if (StringUtils.isBlank(this.getId()) || StringUtils.isBlank(account) || accountObj == null) { // no login
        return publishObj;
    }//from  w w  w.ja  v  a 2  s .c o  m
    if (!account.equals(accountObj.getAccount())) { // not same account request
        return publishObj;
    }
    List<TbSysMsgNotice> globalSysMsgNoticeList = this.loadGlobalSysMsgNoticeData(config.getMsgId(), "*");
    List<TbSysMsgNotice> accountSysMsgNoticeList = this.loadAccountSysMsgNoticeData(config.getMsgId(), account);
    String globalMsg = this.process(sessionId, refreshUUID, globalSysMsgNoticeList);
    String personalMsg = this.process(sessionId, refreshUUID, accountSysMsgNoticeList);
    publishObj.setIsAuthorize(YesNo.YES);
    publishObj.setLogin(YesNo.YES);
    publishObj.setSuccess(YesNo.YES);
    publishObj.setMessage(globalMsg + personalMsg);
    return publishObj;
}