List of usage examples for javax.servlet.http HttpServletRequest removeAttribute
public void removeAttribute(String name);
From source file:grails.plugin.springsecurity.web.filter.DebugFilter.java
protected void invokeWithWrappedRequest(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException { request.setAttribute(ALREADY_FILTERED_ATTR_NAME, true); request = new HttpServletRequestWrapper(request) { @Override/*from www . j a v a 2 s . c o m*/ public HttpSession getSession() { boolean sessionExists = super.getSession(false) != null; HttpSession session = super.getSession(); if (!sessionExists) { log(true, "New HTTP session created: {}", session.getId()); } return session; } @Override public HttpSession getSession(boolean create) { return create ? getSession() : super.getSession(false); } }; try { filterChainProxy.doFilter(request, response, filterChain); } finally { request.removeAttribute(ALREADY_FILTERED_ATTR_NAME); } }
From source file:com.opencnc.controllers.UsuarioController.java
/** * ***************************************************************************** * Recibe el "id" del usuario y lo borra de la base de datos. * ***************************************************************************** * @param id/*from w w w . ja v a2s. c om*/ * @param request * @param response * @return * @throws IOException */ @RequestMapping("/usuario/borrar/{id}") public ModelAndView borrar(@PathVariable Integer id, HttpServletRequest request, HttpServletResponse response) throws IOException { HttpSession sess = request.getSession(); if (sess != null) { Usuario us = (Usuario) sess.getAttribute("usuario"); Session s = HibernateUtil.getSessionFactory().openSession(); Usuario u = (Usuario) s.get(Usuario.class, id); if (us.getUsuarioId() == u.getUsuarioId()) { return lista(request, response); } else { Transaction t = s.beginTransaction(); s.delete(u); t.commit(); logger.info("Borrar usuario"); return lista(request, response); } } else { request.removeAttribute("usuario"); return new ModelAndView("redirect:/usuario/login.htm"); } }
From source file:com.cyclopsgroup.waterview.jsp.JspEngine.java
/** * @param path Absolute JSP path/* w w w. ja v a 2s . com*/ * @param data Runtime data * @param viewContext View context * @throws Exception Throw it out */ public void renderJsp(String path, RuntimeData data, Context viewContext) throws Exception { HttpServletRequest request = (HttpServletRequest) data.getRequestContext().get("request"); HttpServletResponse response = (HttpServletResponse) data.getRequestContext().get("response"); ServletContext servletContext = (ServletContext) data.getRequestContext().get("servletContext"); if (request == null || response == null || servletContext == null) { data.getOutput().println("Jsp " + path + " is not rendered correctly with request " + request + ", response " + response + ", context " + servletContext); } request.setAttribute("viewContext", viewContext); RequestDispatcher dispatcher = servletContext.getRequestDispatcher(path); File jspFile = new File(servletContext.getRealPath(path)); if (dispatcher == null || !jspFile.isFile()) { data.getOutput().println("Jsp " + path + " doesn't exist"); } else { dispatcher.include(request, response); response.getWriter().flush(); } request.removeAttribute("viewContext"); }
From source file:com.glaf.oa.seal.web.springmvc.SealController.java
@RequestMapping("/review") public ModelAndView review(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Seal seal = sealService.getSeal(RequestUtils.getLong(request, "sealid")); if (seal != null) { request.setAttribute("seal", seal); JSONObject rowJSON = seal.toJsonObject(); request.setAttribute("x_json", rowJSON.toJSONString()); }// ww w. j a v a2 s . c om boolean canUpdate = false; String x_method = request.getParameter("x_method"); if (StringUtils.equals(x_method, "submit")) { } if (StringUtils.containsIgnoreCase(x_method, "update")) { if (seal != null) { if (seal.getStatus() == 0 || seal.getStatus() == -1) { canUpdate = true; } } } if (RequestUtils.getBoolean(request, "lookover")) { request.setAttribute("lookover", true); } else { request.setAttribute("lookover", false); } request.setAttribute("canUpdate", canUpdate); String view = request.getParameter("view"); if (StringUtils.isNotEmpty(view)) { return new ModelAndView(view, modelMap); } String x_view = ViewProperties.getString("seal.edit"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } String appusername = BaseDataManager.getInstance().getStringValue(seal.getAppuser(), "SYS_USERS"); request.setAttribute("appusername", appusername); return new ModelAndView("/oa/seal/sealReview", modelMap); }
From source file:com.virtusa.akura.student.controller.RejoinSuspendedStudentController.java
/** * Initializes the reference data that is to be previewed on the UI. * //from w ww . ja v a 2 s .c o m * @param request - an object of HttpServletRequest * @param student - an instance of Student * @param model - a HashMap that contains information of the suspended student 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_STUDENT_SUSPEND_DETAILS_HTM) public final String viewSuspendedStudentDetails(final ModelMap model, final HttpSession session, final HttpServletRequest request, @ModelAttribute(STUDENT) final Student student) throws AkuraAppException { String studentId = request.getParameter(SELECTED_STUDENT_ID); String studentIdAttribute = (String) session.getAttribute(SELECTED_STUDENT_ID); String message = request.getParameter(MESSAGE); if (studentId == null && studentIdAttribute != null) { studentId = studentIdAttribute; session.removeAttribute(SELECTED_STUDENT_ID); if (message != null) { model.addAttribute(MESSAGE, message); request.removeAttribute(MESSAGE); } } setSuspendedStudentList(model, studentId); SuspendStudent suspendStudent = new SuspendStudent(); model.addAttribute(SUSPEND_STUDENT, suspendStudent); return VIEW_GET_SUSPENDED_STUDENT_REJOIN; }
From source file:com.opencnc.controllers.SentenciaController.java
/** * ***************************************************************************** * Crea la sentencia.//from w w w . j a va 2 s. c o m * ***************************************************************************** * @param id * @param request * @param response * @return * @throws Exception */ @RequestMapping("/sentencia/crear/{id}") public ModelAndView crear(@PathVariable Integer id, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession sess = request.getSession(); if (sess != null) { Sentencia sen = new Sentencia(); Session s = HibernateUtil.getSessionFactory().openSession(); // no es el id que se debe usar ElementoGrafico e = (ElementoGrafico) s.get(ElementoGrafico.class, id); Programa p = (Programa) s.get(Programa.class, id); Comando com = (Comando) s.get(Comando.class, id); sen.setElementoGrafico(e); sen.setPrograma(p); sen.setComando(com); Transaction t = s.getTransaction(); s.beginTransaction(); s.saveOrUpdate(sen); t.commit(); ModelAndView m = new ModelAndView("/sentencia/crear"); m.addObject("sentencia", s); return m; } else { request.removeAttribute("usuario"); return new ModelAndView("redirect:/usuario/login.htm"); } }
From source file:com.glaf.oa.salescontract.web.springmvc.SalescontractController.java
@RequestMapping("/review") public ModelAndView review(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Salescontract salescontract = salescontractService.getSalescontract(RequestUtils.getLong(request, "id")); if (salescontract != null) { request.setAttribute("salescontract", salescontract); JSONObject rowJSON = salescontract.toJsonObject(); request.setAttribute("x_json", rowJSON.toJSONString()); // ???// ww w .j a v a2 s .c o m String appusername = BaseDataManager.getInstance().getStringValue(salescontract.getAppuser(), "SYS_USERS"); request.setAttribute("appusername", appusername); } if (RequestUtils.getBoolean(request, "lookover")) { request.setAttribute("lookover", true); } else { request.setAttribute("lookover", false); } boolean canUpdate = false; String x_method = request.getParameter("x_method"); if (StringUtils.equals(x_method, "submit")) { } if (StringUtils.containsIgnoreCase(x_method, "update")) { if (salescontract != null) { if (salescontract.getStatus() == 0 || salescontract.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("salescontract.edit"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/oa/salesContract/salesContractReview", modelMap); }
From source file:com.opencnc.controllers.ModeloController.java
/** * ***************************************************************************** * Borra los modelos//from ww w. j a va 2 s.c o m * ***************************************************************************** * @param id * @param request * @param response * @return * @throws Exception */ @RequestMapping("/modelo/borrarModelo/{id}") public ModelAndView borrarModelo(@PathVariable Integer id, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession sess = request.getSession(); if (sess != null) { Session s = HibernateUtil.getSessionFactory().openSession(); Usuario us = (Usuario) sess.getAttribute("usuario"); Modelo u = (Modelo) s.get(Modelo.class, id); //Mala practica para borrado de modelo. u.setCreadoPor(1); /* Transaction t = s.beginTransaction(); s.delete(u); t.commit(); */ Transaction t = s.getTransaction(); s.beginTransaction(); s.saveOrUpdate(u); t.commit(); //return new ModelAndView("redirect:/usuario/login.htm"); //return abrir(1); return abrir(request, response); } else { request.removeAttribute("usuario"); return new ModelAndView("redirect:/usuario/login.htm"); } }
From source file:atd.backend.Login.java
/** * Vangt het POST request van de login.jsp en controlleerd deze met de * database//from ww w .j a v a2 s . co m */ @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String username = req.getParameter("username").toLowerCase(); try { Class.forName("org.apache.commons.codec.digest.DigestUtils"); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } String pass = org.apache.commons.codec.digest.DigestUtils.sha256Hex(req.getParameter("password")); RequestDispatcher rd = null; if (UsersDAO.authUser(username, pass) || (username.equals(adminUser)) && req.getParameter("password").equals(adminPwd)) { // Controlleer of het filter een redirect gezet heeft if (req.getAttribute("redirect") == null || req.getAttribute("redirect").equals("")) { rd = req.getRequestDispatcher("/index.jsp"); } else { rd = req.getRequestDispatcher((String) req.getAttribute("redirect")); req.removeAttribute("redirect"); } req.getSession().setAttribute("username", UsersDAO.searchUser(username)); resp.addCookie(new Cookie("username", username)); java.util.Date dt = new java.util.Date(); java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String currentTime = sdf.format(dt); LogDAO.setLog(req.getRemoteAddr(), currentTime, UsersDAO.searchUser(username), null); rd.forward(req, resp); } else if (KlantenDAO.authKlant(username, pass)) { if (req.getAttribute("redirect") == null || req.getAttribute("redirect").equals("")) { rd = req.getRequestDispatcher("/index.jsp"); } else { rd = req.getRequestDispatcher((String) req.getAttribute("redirect")); req.removeAttribute("redirect"); } req.getSession().setAttribute("username", KlantenDAO.searchKlant(username)); System.out.println("klant setten"); resp.addCookie(new Cookie("username", username)); java.util.Date dt = new java.util.Date(); java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String currentTime = sdf.format(dt); LogDAO.setLog(req.getRemoteAddr(), currentTime, null, KlantenDAO.searchKlant(username)); rd.forward(req, resp); } else { rd = req.getRequestDispatcher("/login/login.jsp"); req.setAttribute("error", "<div class=\"alert alert-danger\" role=\"alert\"> <span class=\"sr-only\">Error:</span> ongeldige inlog gegevens </div>"); rd.forward(req, resp); } }
From source file:org.fenixedu.academic.ui.struts.action.publico.ChooseExamsMapContextDANew.java
public ActionForward prepare(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String degreeId = getFromRequest("degreeID", request); request.setAttribute("degreeID", degreeId); Degree degree = FenixFramework.getDomainObject(degreeId); request.setAttribute("degree", degree); String executionDegreeId = getFromRequest("executionDegreeID", request); request.setAttribute("executionDegreeID", executionDegreeId); String degreeCurricularPlanId = getFromRequest("degreeCurricularPlanID", request); request.setAttribute("degreeCurricularPlanID", degreeCurricularPlanId); List<LabelValueBean> executionPeriodsLabelValueList = buildExecutionPeriodsLabelValueList( degreeCurricularPlanId);//from w ww .j a v a 2s. com if (executionPeriodsLabelValueList.size() > 1) { request.setAttribute("lista", executionPeriodsLabelValueList); } else { request.removeAttribute("lista"); } Boolean inEnglish = getFromRequestBoolean("inEnglish", request); if (inEnglish == null) { inEnglish = getLocale(request).getLanguage().equals(Locale.ENGLISH.getLanguage()); } request.setAttribute("inEnglish", inEnglish); request.removeAttribute(PresentationConstants.LABELLIST_EXECUTIONPERIOD); return mapping.findForward("prepare"); }