List of usage examples for javax.servlet.http HttpServletRequest removeAttribute
public void removeAttribute(String name);
From source file:com.glaf.oa.purchase.web.springmvc.PurchaseController.java
@RequestMapping("/edit") public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) { User user = RequestUtils.getUser(request); String actorId = user.getActorId(); RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Purchase purchase = purchaseService.getPurchase(RequestUtils.getLong(request, "purchaseId")); if (purchase == null) { purchase = new Purchase(); purchase.setStatus(-1);// SysDepartment sysDepartment = BaseDataManager.getInstance().getSysDepartmentService() .findById(user.getDeptId()); String areaCode = ""; if (sysDepartment.getCode() != null && sysDepartment.getCode().length() >= 2) { areaCode = sysDepartment.getCode().substring(0, 2); }//from www . j av a2 s .co m purchase.setArea(areaCode);// purchase.setDept(sysDepartment.getCode());// purchase.setPost(RequestUtil.getLoginUser(request).getHeadship());// ?? purchase.setAppuser(actorId); purchase.setAppdate(new Date()); purchase.setCreateBy(actorId); purchaseService.save(purchase); } request.setAttribute("purchase", purchase); JSONObject rowJSON = purchase.toJsonObject(); request.setAttribute("x_json", rowJSON.toJSONString()); boolean canUpdate = false; String x_method = request.getParameter("x_method"); if (StringUtils.equals(x_method, "submit")) { } if (StringUtils.containsIgnoreCase(x_method, "update")) { if (purchase != null) { if (purchase.getStatus() == 0 || purchase.getStatus() == -1) { canUpdate = true; } } } request.setAttribute("canUpdate", canUpdate); String view = request.getParameter("view"); if (StringUtils.isNotEmpty(view)) { return new ModelAndView(view, modelMap); } String x_view = ViewProperties.getString("purchase.edit"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/oa/purchase/edit", modelMap); }
From source file:com.sammyun.interceptor.LogInterceptor.java
@SuppressWarnings("unchecked") @Override// www.jav a 2 s. c o 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 = EduUtil.getAddr(request); 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:org.springframework.boot.actuate.metrics.web.servlet.MetricsFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { StopWatch stopWatch = createStopWatchIfNecessary(request); String path = new UrlPathHelper().getPathWithinApplication(request); int status = HttpStatus.INTERNAL_SERVER_ERROR.value(); try {//from www . j av a 2s. c o m chain.doFilter(request, response); status = getStatus(response); } finally { if (!request.isAsyncStarted()) { if (response.isCommitted()) { status = getStatus(response); } stopWatch.stop(); request.removeAttribute(ATTRIBUTE_STOP_WATCH); recordMetrics(request, path, status, stopWatch.getTotalTimeMillis()); } } }
From source file:com.virtusa.akura.staff.controller.StaffPastServiceController.java
/** * Initializes the reference data that is to be previewed on the UI. * // w ww . java 2s . c o m * @param request - an object of HttpServletRequest * @param staff - an instance of Staff * @param model - a HashMap that contains information of the Past staff service. * @param session - a session to pass values. * @return - name of the view which is redirected to * @throws AkuraAppException - The exception details that occurred when processing. */ @RequestMapping(value = ADMIN_MANAGE_VIEW_PAST_STAFF_SERVICE_HTM) public final String viewPastStaffService(final ModelMap model, final HttpSession session, final HttpServletRequest request, @ModelAttribute(STAFF) final Staff staff) throws AkuraAppException { String staffId = request.getParameter(SELECTED_STAFF_ID); String staffIdAttribute = (String) session.getAttribute(SELECTED_STAFF_ID); String message = request.getParameter(MESSAGE); if (staffId == null && staffIdAttribute != null) { staffId = staffIdAttribute; session.removeAttribute(SELECTED_STAFF_ID); if (message != null) { model.addAttribute(MESSAGE, message); request.removeAttribute(MESSAGE); } } setStaffPastServiceList(model, staffId); StaffPastService staffPastService = new StaffPastService(); model.addAttribute(STAFF_PAST_SERVICE, staffPastService); return VIEW_GET_PAST_STAFF_SERVICE; }
From source file:org.apache.struts.util.ModuleUtils.java
/** * Select the module to which the specified request belongs, and add * corresponding request attributes to this request. * * @param prefix The module prefix of the desired module * @param request The servlet request we are processing * @param context The ServletContext for this web application *///from w w w. j ava 2s .com public void selectModule(String prefix, HttpServletRequest request, ServletContext context) { // Expose the resources for this module ModuleConfig config = getModuleConfig(prefix, context); if (config != null) { request.setAttribute(Globals.MODULE_KEY, config); MessageResourcesConfig[] mrConfig = config.findMessageResourcesConfigs(); for (int i = 0; i < mrConfig.length; i++) { String key = mrConfig[i].getKey(); MessageResources resources = (MessageResources) context.getAttribute(key + prefix); if (resources != null) { request.setAttribute(key, resources); } else { request.removeAttribute(key); } } } else { request.removeAttribute(Globals.MODULE_KEY); } }
From source file:com.glaf.oa.assessresult.web.springmvc.AssessresultController.java
@RequestMapping("/edit") public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Assessresult assessresult = assessresultService.getAssessresult(RequestUtils.getLong(request, "resultid")); if (assessresult != null) { request.setAttribute("assessresult", assessresult); JSONObject rowJSON = assessresult.toJsonObject(); request.setAttribute("x_json", rowJSON.toJSONString()); }// ww w. j a v a 2 s .c o m boolean canUpdate = false; String x_method = request.getParameter("x_method"); if (StringUtils.equals(x_method, "submit")) { } if (StringUtils.containsIgnoreCase(x_method, "update")) { if (assessresult != null) { canUpdate = true; } } request.setAttribute("canUpdate", canUpdate); String view = request.getParameter("view"); if (StringUtils.isNotEmpty(view)) { return new ModelAndView(view, modelMap); } String x_view = ViewProperties.getString("assessresult.edit"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/oa/assessresult/edit", modelMap); }
From source file:com.glaf.oa.reimbursement.web.springmvc.ReimbursementController.java
@RequestMapping("/edit") public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) { User user = RequestUtils.getUser(request); String actorId = user.getActorId(); RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Reimbursement reimbursement = reimbursementService .getReimbursement(RequestUtils.getLong(request, "reimbursementid")); if (reimbursement == null) { reimbursement = new Reimbursement(); reimbursement.setStatus(-1);// SysDepartment sysDepartment = BaseDataManager.getInstance().getSysDepartmentService() .findById(user.getDeptId()); String areaCode = ""; if (sysDepartment.getCode() != null && sysDepartment.getCode().length() >= 2) { areaCode = sysDepartment.getCode().substring(0, 2); }/* ww w. ja va2s . co m*/ reimbursement.setAppuser(actorId); reimbursement.setArea(areaCode);// reimbursement.setDept(sysDepartment.getCode());// reimbursement.setPost(RequestUtil.getLoginUser(request).getHeadship());// ?? reimbursement.setAppdate(new Date()); reimbursement.setCreateBy(actorId); reimbursementService.save(reimbursement); } if (reimbursement.getBrands1() != null && reimbursement.getBrands2() != null) { reimbursement.setBrand("MUL"); } request.setAttribute("reimbursement", reimbursement); JSONObject rowJSON = reimbursement.toJsonObject(); request.setAttribute("x_json", rowJSON.toJSONString()); boolean canUpdate = false; String x_method = request.getParameter("x_method"); if (StringUtils.equals(x_method, "submit")) { } if (StringUtils.containsIgnoreCase(x_method, "update")) { if (reimbursement != null) { if (reimbursement.getStatus() == 0 || reimbursement.getStatus() == -1) { canUpdate = true; } } } request.setAttribute("canUpdate", canUpdate); String view = request.getParameter("view"); if (StringUtils.isNotEmpty(view)) { return new ModelAndView(view, modelMap); } String x_view = ViewProperties.getString("reimbursement.edit"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/oa/reimbursement/edit", modelMap); }
From source file:org.josso.gateway.protocol.handler.NtlmProtocolHandler.java
protected boolean negotiate(HttpServletRequest req, HttpServletResponse resp, boolean skipAuthentication) throws IOException, ServletException { UniAddress dc;// w w w . j av a 2 s . c o m String msg; NtlmPasswordAuthentication ntlm; msg = req.getHeader("Authorization"); // Checks for loging errors Object error = req.getAttribute(NTLM_ERROR_FLAG); if (error != null) { if (logger.isDebugEnabled()) logger.debug("Restarts negotiation due to authentication error"); req.removeAttribute(NTLM_ERROR_FLAG); this.startsNegotiation(req, resp); return false; } //if no error go on with the default handshake if (msg != null && (msg.startsWith("NTLM ") || (this.isOfferBasic(req) && msg.startsWith("Basic ")))) { if (msg.startsWith("NTLM ")) { HttpSession ssn = req.getSession(); byte[] challenge; if (loadBalance) { NtlmChallenge chal = (NtlmChallenge) ssn.getAttribute("NtlmHttpChal"); if (chal == null) { chal = SmbSession.getChallengeForDomain(); ssn.setAttribute("NtlmHttpChal", chal); } dc = chal.dc; challenge = chal.challenge; } else { dc = UniAddress.getByName(domainController, true); challenge = SmbSession.getChallenge(dc); } // NTLM Authentication if ((ntlm = NtlmSsp.authenticate(req, resp, challenge)) == null) { // Auth Failed req.setAttribute(NTLM_ERROR_FLAG, "AUTHN_ERROR"); return true; } /* negotiation complete, remove the challenge object */ ssn.removeAttribute("NtlmHttpChal"); } else { String auth = new String(Base64.decode(msg.substring(6)), "US-ASCII"); int index = auth.indexOf(':'); String user = (index != -1) ? auth.substring(0, index) : auth; String password = (index != -1) ? auth.substring(index + 1) : ""; index = user.indexOf('\\'); if (index == -1) index = user.indexOf('/'); String domain = (index != -1) ? user.substring(0, index) : defaultDomain; user = (index != -1) ? user.substring(index + 1) : user; ntlm = new NtlmPasswordAuthentication(domain, user, password); dc = UniAddress.getByName(domainController, true); } req.getSession().setAttribute(NTLM_DOMAIN_CONTROLLER, dc); req.getSession().setAttribute(NTLM_PASS_AUTHENTICATION, ntlm); } else { if (!skipAuthentication) { HttpSession ssn = req.getSession(false); if (ssn == null || (ssn.getAttribute(NTLM_PASS_AUTHENTICATION) == null)) { this.startsNegotiation(req, resp); return false; } } } return true; }
From source file:edu.utah.further.i2b2.hook.further.FurtherInterceptionFilter.java
/** * @param request//from www .ja v a 2 s . c o m * @param originalResponseBytes * @return */ private byte[] modifyI2b2Response(final HttpServletRequest request, final String i2b2Response) { String originalResponse = i2b2Response; if (log.isDebugEnabled()) { log.debug("Response: " + originalResponse); } final QueryContextIdentifierTo id = (QueryContextIdentifierTo) request.getAttribute(QUERY_ID); if (id == null) { throw new IllegalStateException("Did not obtain an acknowledgment from the FURTHeR FQE; check " + "that the FQE WS init-param is set to the correct value in web.xml and in the code"); } // Clean up request.removeAttribute(QUERY_ID); final QueryContextTo queryContextTo = furtherServices.getQuery(id); originalResponse = originalResponse.replaceAll("<set_size>[0-9]+</set_size>", furtherServices.buildQueryResultXml(queryContextTo)); return originalResponse.getBytes(); }
From source file:com.glaf.oa.withdrawal.web.springmvc.WithdrawalController.java
@RequestMapping("/edit") public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) { User user = RequestUtils.getUser(request); String actorId = user.getActorId(); RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Withdrawal withdrawal = withdrawalService.getWithdrawal(RequestUtils.getLong(request, "withdrawalid")); if (withdrawal == null) { withdrawal = new Withdrawal(); withdrawal.setStatus(-1);// SysDepartment sysDepartment = BaseDataManager.getInstance().getSysDepartmentService() .findById(user.getDeptId()); String areaCode = ""; if (sysDepartment.getCode() != null && sysDepartment.getCode().length() >= 2) { areaCode = sysDepartment.getCode().substring(0, 2); }//from w w w. ja v a 2 s. c o m withdrawal.setAppuser(actorId); withdrawal.setArea(areaCode);// withdrawal.setDept(sysDepartment.getCode());// withdrawal.setPost(RequestUtil.getLoginUser(request).getHeadship());// ?? withdrawal.setAppdate(new Date()); withdrawal.setCreateBy(actorId); withdrawal.setCreateDate(new Date()); withdrawalService.save(withdrawal); } 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"); } request.setAttribute("withdrawal", withdrawal); JSONObject rowJSON = withdrawal.toJsonObject(); request.setAttribute("x_json", rowJSON.toJSONString()); } boolean canUpdate = false; String x_method = request.getParameter("x_method"); if (StringUtils.equals(x_method, "submit")) { } if (StringUtils.containsIgnoreCase(x_method, "update")) { if (withdrawal != null) { if (withdrawal.getStatus() == 0 || withdrawal.getStatus() == -1) { canUpdate = true; } } } request.setAttribute("canUpdate", canUpdate); String view = request.getParameter("view"); if (StringUtils.isNotEmpty(view)) { return new ModelAndView(view, modelMap); } String x_view = ViewProperties.getString("withdrawal.edit"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/oa/withdrawal/edit", modelMap); }