List of usage examples for javax.servlet.http HttpServletRequest removeAttribute
public void removeAttribute(String name);
From source file:com.adito.core.CoreUtil.java
/** * @param request/* w w w. ja va 2s . co m*/ * @param warnings */ public static void addWarnings(HttpServletRequest request, ActionMessages warnings) { if (warnings == null) { return; } ActionMessages requestWarnings = (ActionMessages) request.getAttribute(Constants.REQ_ATTR_WARNINGS); if (requestWarnings == null) { requestWarnings = new ActionMessages(); } requestWarnings.add(warnings); if (requestWarnings.isEmpty()) { request.removeAttribute(Constants.REQ_ATTR_WARNINGS); return; } request.setAttribute(Constants.REQ_ATTR_WARNINGS, requestWarnings); }
From source file:com.octo.captcha.module.struts.VerifyCaptchaChallengeAction.java
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { log.debug("enter captcha challenge verification"); CaptchaService service = CaptchaServicePlugin.getInstance().getService(); String responseKey = CaptchaServicePlugin.getInstance().getResponseKey(); String captchaID;/*from w w w. j ava 2 s .c o m*/ captchaID = CaptchaModuleConfigHelper.getId(httpServletRequest); // get challenge response from the request String challengeResponse = httpServletRequest.getParameter(responseKey); if (log.isDebugEnabled()) log.debug("response for id " + captchaID + " : " + challengeResponse); //cleanning the request httpServletRequest.removeAttribute(responseKey); Boolean isResponseCorrect = Boolean.FALSE; if (challengeResponse != null) { // Call the Service method try { isResponseCorrect = service.validateResponseForID(captchaID, challengeResponse); } catch (CaptchaServiceException e) { log.debug("Error during challenge verification", e); // so the user will be redirected to the error page httpServletRequest.setAttribute(CaptchaServicePlugin.getInstance().getMessageKey(), CaptchaModuleConfigHelper.getMessage(httpServletRequest)); log.debug("forward to error with message : " + CaptchaModuleConfigHelper.getMessage(httpServletRequest)); return actionMapping.findForward("error"); } } // forward user to the success URL or redirect it to the error URL if (isResponseCorrect.booleanValue()) { // clean the request and call the next action // (forward success) log.debug("correct : forward to success"); return actionMapping.findForward("success"); } else { if (log.isDebugEnabled()) { log.debug("false : forward to failure with message : " + CaptchaModuleConfigHelper.getMessage(httpServletRequest)); log.debug("in request attribute key : " + CaptchaServicePlugin.getInstance().getMessageKey()); } // If the challenge response is not specified, forward failure httpServletRequest.setAttribute(CaptchaServicePlugin.getInstance().getMessageKey(), CaptchaModuleConfigHelper.getMessage(httpServletRequest)); return actionMapping.findForward("failure") != null ? actionMapping.findForward("failure") : actionMapping.getInputForward(); } }
From source file:org.pentaho.platform.web.http.filters.PentahoRequestContextFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; if (httpRequest.getAttribute(FILTER_APPLIED) != null) { // ensure that filter is only applied once per request chain.doFilter(httpRequest, httpResponse); return;//from www . j a va 2 s . c o m } httpRequest.setAttribute(FILTER_APPLIED, Boolean.TRUE); try { if (requestContext == null) { initContext(httpRequest); } PentahoRequestContextHolder.setRequestContext(requestContext); chain.doFilter(httpRequest, httpResponse); } finally { PentahoRequestContextHolder.removeRequestContext(); httpRequest.removeAttribute(FILTER_APPLIED); if (logger.isDebugEnabled()) { logger.debug("PentahoRequestContextHolder now cleared, as request processing completed"); } } }
From source file:com.glaf.oa.withdrawal.web.springmvc.WithdrawalController.java
@RequestMapping("/view") public ModelAndView view(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Withdrawal withdrawal = withdrawalService.getWithdrawal(RequestUtils.getLong(request, "withdrawalid")); if (withdrawal != null) { if (withdrawal.getBrands1() != null && withdrawal.getBrands2() != null) { withdrawal.setBrand("MUL"); } else if (withdrawal.getBrands1() != null && withdrawal.getBrands2() == null) { withdrawal.setBrand("FLL"); } else if (withdrawal.getBrands1() == null && withdrawal.getBrands2() != null) { withdrawal.setBrand("MSLD"); }/* ww w .j av a2 s . c o m*/ request.setAttribute("withdrawal", withdrawal); JSONObject rowJSON = withdrawal.toJsonObject(); request.setAttribute("x_json", rowJSON.toJSONString()); } return new ModelAndView("/oa/withdrawal/view", modelMap); }
From source file:com.opencnc.controllers.UsuarioController.java
/** * ***************************************************************************** * Recibe el parametro "id" para editar el usuario ya creado. * ***************************************************************************** * @param id// w w w.j a va2 s . co m * @param request * @param response * @return * @throws IOException */ @RequestMapping("/usuario/editar/{id}") public ModelAndView editar(@PathVariable Integer id, HttpServletRequest request, HttpServletResponse response) throws IOException { HttpSession sess = request.getSession(); if (sess != null) { Session s = HibernateUtil.getSessionFactory().openSession(); Usuario u = (Usuario) s.get(Usuario.class, id); ModelAndView m = new ModelAndView("/usuario/editar"); m.addObject("usuario", u); logger.info("Empieza a mostrar lista"); return m; } else { request.removeAttribute("usuario"); return new ModelAndView("redirect:/usuario/login.htm"); } }
From source file:com.att.ajsc.csilogging.common.CSILoggingUtils.java
private void sendCsiLog(HttpServletRequest request, QueueConnector connector) { if (request.getAttribute(CommonNames.AUDIT_LOG) != null) { connector.sendAuditLog(request.getAttribute(CommonNames.AUDIT_LOG).toString()); request.removeAttribute(CommonNames.AUDIT_LOG); }//from w ww. j a v a 2 s . c o m if (request.getAttribute(CommonNames.PERFORMANCE_LOG) != null) { connector.sendPerformanceLog(request.getAttribute(CommonNames.PERFORMANCE_LOG).toString()); request.removeAttribute(CommonNames.PERFORMANCE_LOG); } }
From source file:org.hifivault.geo.location.taglib.BaseGeoTargetTag.java
@Override public void doTag() throws JspException, IOException { PageContext ctx = (PageContext) getJspContext(); HttpServletRequest req = (HttpServletRequest) ctx.getRequest(); HttpSession session = ctx.getSession(); String mappedCode = defaultId(); GeoInfo geo = (GeoInfo) session.getAttribute(GeoLocationManager.getGeoInfoAttribute()); if (geo != null) { String source = geo.getCountryCode(); String code = geo.getTargetCode(); mappedCode = mapId(code);//from w w w .jav a 2 s . c o m if (log.isDebugEnabled()) { log.debug("====>GeoLocate: '" + source + "/" + code + "' to '" + mappedCode + "'"); } } // handle result if (var != null) { // put in variable if (mappedCode.length() > 0) { req.setAttribute(var, mappedCode); } else { req.removeAttribute(var); } } else { // write ctx.getOut().print(mappedCode); } }
From source file:com.dp2345.interceptor.LogInterceptor.java
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { List<LogConfig> logConfigs = logConfigService.getAll(); if (logConfigs != null) { String path = request.getServletPath(); for (LogConfig logConfig : logConfigs) { if (antPathMatcher.match(logConfig.getUrlPattern(), path)) { String username = adminService.getCurrentUsername(); String operation = logConfig.getOperation(); String operator = username; String content = (String) request.getAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME); String ip = request.getRemoteAddr(); request.removeAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME); StringBuffer parameter = new StringBuffer(); Map<String, String[]> parameterMap = request.getParameterMap(); if (parameterMap != null) { for (Entry<String, String[]> entry : parameterMap.entrySet()) { String parameterName = entry.getKey(); if (!ArrayUtils.contains(ignoreParameters, parameterName)) { String[] parameterValues = entry.getValue(); if (parameterValues != null) { for (String parameterValue : parameterValues) { parameter.append(parameterName + " = " + parameterValue + "\n"); }// ww w. j a va 2s.co m } } } } Log log = new Log(); log.setOperation(operation); log.setOperator(operator); log.setContent(content); log.setParameter(parameter.toString()); log.setIp(ip); logService.save(log); break; } } } }
From source file:net.groupbuy.interceptor.LogInterceptor.java
@SuppressWarnings("unchecked") @Override//from w w w .j a v a 2 s . co m public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { List<LogConfig> logConfigs = logConfigService.getAll(); if (logConfigs != null) { String path = request.getServletPath(); for (LogConfig logConfig : logConfigs) { if (antPathMatcher.match(logConfig.getUrlPattern(), path)) { String username = adminService.getCurrentUsername(); String operation = logConfig.getOperation(); String operator = username; String content = (String) request.getAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME); String ip = request.getRemoteAddr(); request.removeAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME); StringBuffer parameter = new StringBuffer(); Map<String, String[]> parameterMap = request.getParameterMap(); if (parameterMap != null) { for (Entry<String, String[]> entry : parameterMap.entrySet()) { String parameterName = entry.getKey(); if (!ArrayUtils.contains(ignoreParameters, parameterName)) { String[] parameterValues = entry.getValue(); if (parameterValues != null) { for (String parameterValue : parameterValues) { parameter.append(parameterName + " = " + parameterValue + "\n"); } } } } } Log log = new Log(); log.setOperation(operation); log.setOperator(operator); log.setContent(content); log.setParameter(parameter.toString()); log.setIp(ip); logService.save(log); break; } } } }
From source file:com.hyeb.back.log.LogInterceptor.java
@SuppressWarnings("unchecked") @Override/*from www.ja v a 2 s . c om*/ public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { List<LogConfig> logConfigs = logConfigService.getAll(); if (logConfigs != null) { String path = request.getServletPath(); for (LogConfig logConfig : logConfigs) { if (antPathMatcher.match(logConfig.getUrlPattern(), path)) { String username = sysUserService.getCurrentUsername(); String operation = logConfig.getOperation(); String operator = username; String content = (String) request.getAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME); String ip = request.getRemoteAddr(); request.removeAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME); StringBuffer parameter = new StringBuffer(); Map<String, String[]> parameterMap = request.getParameterMap(); if (parameterMap != null) { for (Entry<String, String[]> entry : parameterMap.entrySet()) { String parameterName = entry.getKey(); if (!ArrayUtils.contains(ignoreParameters, parameterName)) { String[] parameterValues = entry.getValue(); if (parameterValues != null) { for (String parameterValue : parameterValues) { parameter.append(parameterName + " = " + parameterValue + "\n"); } } } } } Log log = new Log(); log.setOperation(operation); log.setOperator(operator); log.setContent(content); log.setParameter(parameter.toString()); log.setIp(ip); logService.save(log); break; } } } }