List of usage examples for javax.servlet.http HttpSession removeAttribute
public void removeAttribute(String name);
From source file:com.esteban.cmms.maven.controller.Imagenes_Controller.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w. ja va 2 s . c o m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String btne = request.getParameter("btn"); if (btne == null) { try { HttpSession sesion = request.getSession(); sesion.removeAttribute("imagenes"); Usuarios user = (Usuarios) sesion.getAttribute("usuario"); FileItemFactory itemFactory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(itemFactory); String btn = null; Maquinas m = new Maquinas(); List<FileItem> items = upload.parseRequest(request); Imagenes pojo = new Imagenes(); pojo.setUserAction(user.getNombre()); for (FileItem item : items) { if (!item.isFormField()) { String contentType = item.getContentType(); if (!contentType.equals("image/png")) { //|| !contentType.equals("image/jpg") continue; } File img = new File( "/home/esteban/NetBeansProjects/" + "CMMS-Maven/src/main/webapp/Imagenes/images_cli", new Date() + item.getName()); item.write(img); pojo.setImagen(img.getName()); } if (item.isFormField()) { if (item.getFieldName().equalsIgnoreCase("maquina")) { int idm = Integer.parseInt(item.getString()); System.out.println("Maquina"); m.setId(idm); pojo.setMaquinas(m); } else if (item.getFieldName().equalsIgnoreCase("btn")) { System.out.println("Guardar cambios"); btn = item.getString().replaceAll("\\s", ""); } else if (item.getFieldName().equalsIgnoreCase("id")) { System.out.println("id imagen"); pojo.setId(Integer.parseInt(item.getString())); } } } pojo.setEstado("Activo"); System.out.println("ste es el boton" + btn); if (btn.equalsIgnoreCase("actualizar")) { new Imagenes_Model().updateImagen(pojo); } else { new Imagenes_Model().addImagen(pojo); } response.sendRedirect("Imagenes"); } catch (FileUploadException ex) { System.out.println(ex); response.sendRedirect("Static_pages/errores.jsp"); } catch (Exception ex) { System.out.println(ex); response.sendRedirect("Static_pages/errores.jsp"); } } else { String btn = btne.replaceAll("\\s", ""); if (btn.equalsIgnoreCase("imagenes")) { Imagenes_Model model = new Imagenes_Model(); HttpSession sesion = request.getSession(); String valor = request.getParameter("valor"); List<Imagenes> result = new ArrayList<Imagenes>(); if (valor.equalsIgnoreCase("activo")) { try { result = model.getAllImagenes(); sesion.setAttribute("imagenes", result); sesion.setAttribute("maquinas", new Maquinas_Model().getAllMaquinas()); } catch (Exception e) { System.out.println(e); response.sendRedirect("Static_pages/errores.jsp"); } response.sendRedirect("Imagenes"); } else if (valor.equalsIgnoreCase("inactivo")) { try { result = model.listNoActive(); sesion.setAttribute("imagenes", result); } catch (Exception e) { System.out.println(e); response.sendRedirect("Static_pages/errores.jsp"); } response.sendRedirect("Imagenes/archivados.jsp"); } } else if (btn.equalsIgnoreCase("estado")) { System.out.println("Definicin de estado"); System.out.println("Nuevo estado: " + request.getParameter("estado")); Usuarios user = (Usuarios) request.getSession().getAttribute("usuario"); try { new Imagenes_Model().estadoImagen(request.getParameter("estado"), Integer.parseInt(request.getParameter("id")), user.getNombre()); } catch (Exception ex) { System.out.println(ex); response.sendRedirect("Static_pages/errores.jsp"); } System.out.println("Estado definido con xito"); response.sendRedirect("Imagenes"); } } }
From source file:edu.cornell.mannlib.vitro.webapp.controller.accounts.user.UserAccountsFirstTimeExternalPage.java
private void checkSessionForExternalLoginInfo() { HttpSession session = vreq.getSession(); Object o = session.getAttribute(ATTRIBUTE_EXTERNAL_LOGIN_INFO); session.removeAttribute(ATTRIBUTE_EXTERNAL_LOGIN_INFO); if (o instanceof ExternalLoginInfo) { externalAuthId = ((ExternalLoginInfo) o).externalAuthId; afterLoginUrl = ((ExternalLoginInfo) o).afterLoginUrl; if (afterLoginUrl == null) { afterLoginUrl = ""; }/*from ww w. j av a 2 s .c o m*/ } }
From source file:gov.nih.nci.ispy.web.ajax.DynamicReportGenerator.java
public void clearTmpReporters() { HttpSession session = ExecutionContext.get().getSession(false); session.removeAttribute("tmpReporterList"); //put back in session }
From source file:gov.nih.nci.ispy.web.ajax.DynamicReportGenerator.java
public void clearTmpGenes() { HttpSession session = ExecutionContext.get().getSession(false); session.removeAttribute("tmpGeneList"); }
From source file:gov.nih.nci.ispy.web.ajax.DynamicReportGenerator.java
public void clearTmpSamplesFromClinical() { HttpSession session = ExecutionContext.get().getSession(false); session.removeAttribute("clinical_tmpSampleList"); //put back in session }
From source file:iddb.web.security.service.CommonUserService.java
protected void invalidateUserSession(HttpServletRequest request, HttpServletResponse response) { context.removeSubject();/*from w w w . ja v a 2 s . c o m*/ String sessionKey = null; HttpSession session = request.getSession(false); if (session != null) { session.removeAttribute(UserService.SUBJECT); sessionKey = (String) session.getAttribute(UserService.SESSION_KEY); session.removeAttribute(UserService.SESSION_KEY); } // remove cookie Cookie cookie = new Cookie("iddb-u", ""); cookie.setPath(request.getContextPath() + "/"); cookie.setMaxAge(0); response.addCookie(cookie); cookie = new Cookie("iddb-k", ""); cookie.setPath(request.getContextPath() + "/"); cookie.setMaxAge(0); response.addCookie(cookie); if (sessionKey != null) { removeSession(sessionKey); } }
From source file:com.idega.slide.authentication.IWSlideAuthenticator.java
/** * @param session//w w w.j a v a2s . com * @throws IBOLookupException */ private void setAsUnauthenticatedInSlide(HttpSession session) throws IBOLookupException { session.removeAttribute(SLIDE_USER_PRINCIPAL_ATTRIBUTE_NAME); }
From source file:cn.loveapple.service.controller.member.action.MemberController.java
/** * ?? * * @param session */ protected void clearMemberInfo(HttpSession session) { session.removeAttribute(LOVEAPPLE_MEMBER); }
From source file:com.betel.flowers.web.bean.CredencialBean.java
public void logout(ActionEvent event) { String url = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath() + "/faces/index.xhtml"; RequestContext context = RequestContext.getCurrentInstance(); FacesContext facesContext = FacesContext.getCurrentInstance(); HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(false); session.removeAttribute(this.userSession.getUsername()); session.invalidate();/*www . j a va 2 s . co m*/ this.init(); context.addCallbackParam("loggerOut", true); context.addCallbackParam("ruta", url); }
From source file:jp.co.opentone.bsol.linkbinder.view.filter.LoginFilter.java
private void startNewSession(HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(false); String oldId = session.getId(); Map<String, Object> attributes = collectSessionAttributes(session); session.invalidate();/*from ww w . jav a 2 s . c o m*/ HttpSession newSession = request.getSession(true); copyAttributes(newSession, attributes); newSession.removeAttribute(Constants.KEY_START_NEW_SESSION); if (log.isDebugEnabled()) { log.debug("session '{}' was invalidated.", oldId); log.debug("session '{}' was started.", newSession.getId()); } }