List of usage examples for javax.servlet.http HttpSession removeAttribute
public void removeAttribute(String name);
From source file:info.magnolia.module.admininterface.DialogMVCHandler.java
public void removeSessionAttributes() { String[] toRemove = form.getParameterValues(DialogControlImpl.SESSION_ATTRIBUTENAME_DIALOGOBJECT_REMOVE); if (toRemove != null) { for (int i = 0; i < toRemove.length; i++) { HttpSession httpsession = this.getRequest().getSession(false); if (httpsession != null) { httpsession.removeAttribute(toRemove[i]); }//from w ww . ja v a 2 s . c o m } } }
From source file:org.carewebframework.security.spring.DesktopSecurityContextRepository.java
/** * Remove desktop security context on desktop cleanup. *///from w w w .j av a 2 s . co m @Override public void onCleanup(Desktop desktop) { HttpSession session = (HttpSession) desktop.getSession().getNativeSession(); session.removeAttribute(getDesktopContextKey(desktop.getId())); }
From source file:org.opencron.server.controller.HomeController.java
@RequestMapping("/logout") public String logout(HttpSession httpSession) throws IOException { //??.//from ww w. j ava2 s .co m TerminalSession.exit(httpSession.getId()); httpSession.removeAttribute(OpencronTools.LOGIN_USER); httpSession.removeAttribute(OpencronTools.LOGIN_MSG); return "redirect:/"; }
From source file:com.redhat.rhn.frontend.struts.StrutsDelegate.java
/** * Add messages to the request/*from w w w .j a va 2 s. c om*/ * @param request Request where messages will be saved. * @param messages Messages to be saved. */ // TODO Write unit tests for saveMessages(HttpServletRequest, ActionMessages) public void saveMessages(HttpServletRequest request, ActionMessages messages) { HttpSession session = request.getSession(); if ((messages == null) || messages.isEmpty()) { session.removeAttribute(Globals.ERROR_KEY); session.removeAttribute(Globals.MESSAGE_KEY); return; } String key = Globals.MESSAGE_KEY; if (messages instanceof ActionErrors) { key = Globals.ERROR_KEY; } ActionMessages newMessages = new ActionMessages(); // Check for existing messages ActionMessages sessionExisting = (ActionMessages) session.getAttribute(key); if (sessionExisting != null) { newMessages.add(sessionExisting); } newMessages.add(messages); session.setAttribute(key, newMessages); request.setAttribute(key, newMessages); }
From source file:controller.ClientController.java
@RequestMapping("/logout") public String logoutAction(HttpSession session) { session.removeAttribute("UserConnected"); session.removeAttribute("compteConnected"); session.removeAttribute("CommercialConnected"); return "redirect:/accueil"; }
From source file:gov.nih.nci.rembrandt.web.ajax.DynamicReportGenerator.java
public void clearTmpSamples() { HttpSession session = ExecutionContext.get().getSession(false); session.removeAttribute("pca_tmpSampleList"); //put back in session }
From source file:nl.nn.adapterframework.webcontrol.action.ActionBase.java
/** * removes formbean <br/>//from ww w. j a va2 s . c o m * removes what is defined under the Attribute of a mapping from either the * request or the session */ public void removeFormBean(ActionMapping mapping, HttpServletRequest request) { HttpSession session = request.getSession(); if (mapping.getAttribute() != null) { if ("request".equals(mapping.getScope())) request.removeAttribute(mapping.getAttribute()); else session.removeAttribute(mapping.getAttribute()); } }
From source file:com.autentia.wuija.web.JasperReportsServlet.java
/** * Clean attributes of session//from www . j ava 2 s.c om * * @param request */ private void autoCleanSession(JasperReport report, HttpServletRequest request) { final HttpSession session = request.getSession(); for (JRParameter param : report.getParameters()) { session.removeAttribute(SESSION_PREFIX + param.getName()); } }
From source file:edu.slu.tpen.servlet.LoginServlet.java
/** * Handles the HTTP <code>POST</code> method by logging in using the given credentials. Credentials * should be specified as a JSON object in the request body. There is also a deprecated way of passing * the credentials as query parameters./* w w w.j a va 2s. co m*/ * * @param req servlet request * @param resp servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { String mail = null, password = null; if (req.getContentLength() > 0) { String contentType = getBaseContentType(req); if (contentType.equals("application/json")) { ObjectMapper mapper = new ObjectMapper(); Map<String, String> creds = mapper.readValue(req.getInputStream(), new TypeReference<Map<String, String>>() { }); mail = creds.get("mail"); password = creds.get("password"); } } else { // Deprecated approach where user-name and password are passed on the query string. mail = req.getParameter("uname"); password = req.getParameter("password"); } if (mail != null && password != null) { User u = new User(mail, password); if (u.getUID() > 0) { HttpSession sess = req.getSession(true); sess.setAttribute("UID", u.getUID()); } else { resp.sendError(HttpServletResponse.SC_UNAUTHORIZED); } } else if (mail == null && password == null) { // Passing null data indicates a logout. HttpSession sess = req.getSession(true); sess.removeAttribute("UID"); resp.setStatus(HttpServletResponse.SC_NO_CONTENT); } else { // Only supplied one of user-id and password. resp.sendError(HttpServletResponse.SC_UNAUTHORIZED); } } catch (NoSuchAlgorithmException ex) { reportInternalError(resp, ex); } }