Example usage for javax.servlet.http HttpSession invalidate

List of usage examples for javax.servlet.http HttpSession invalidate

Introduction

In this page you can find the example usage for javax.servlet.http HttpSession invalidate.

Prototype

public void invalidate();

Source Link

Document

Invalidates this session then unbinds any objects bound to it.

Usage

From source file:edu.lternet.pasta.portal.LogoutServlet.java

/**
 * The doPost method of the servlet. <br>
 *
 * This method is called when a form has its tag value method equals to post.
 * /*from   w ww  . ja  v  a  2s.  c om*/
 * @param request the request send by the client to the server
 * @param response the response send by the server to the client
 * @throws ServletException if an error occurred
 * @throws IOException if an error occurred
 */
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    HttpSession httpSession = request.getSession();
    String uid = (String) httpSession.getAttribute("uid");

    if (uid == null) {
        logger.error("User identifier \"uid\" is null\n");
        httpSession.invalidate();
    } else {
        TokenManager tokenManager = new TokenManager();
        try {
            tokenManager.deleteToken(uid);
        } catch (Exception e) {
            handleDataPortalError(logger, e);
        } finally {
            httpSession.invalidate();
        }
    }

    RequestDispatcher requestDispatcher = request.getRequestDispatcher("./home.jsp");
    requestDispatcher.forward(request, response);

}

From source file:com.mylab.TransmitMailBean.java

public void logout() {
    HttpSession session = jsp.getRequest().getSession(false);
    if (session != null) {
        session.invalidate();
    }
}

From source file:de.itsvs.cwtrpc.security.AbstractRpcFailureHandler.java

protected void invalidateSession(HttpServletRequest request) {
    final HttpSession session;

    session = request.getSession(false);
    if (session != null) {
        if (log.isDebugEnabled()) {
            log.debug("Invalidating session " + session.getId());
        }/*from ww w. j  a v  a2 s  .c o  m*/
        session.invalidate();
    }
}

From source file:io.github.benas.todolist.web.controller.UserController.java

/**
 * *******************//from w ww. ja  v  a2s .com
 * Delete Account
 * ********************
 */

@RequestMapping(value = "/user/account/delete.do", method = RequestMethod.POST)
public String deleteAccount(HttpSession session) {
    userService.remove(sessionData.getUser());
    sessionData.setUser(null);
    session.invalidate();
    return "index";
}

From source file:org.wso2.carbon.server.admin.module.handler.AuthenticationHandler.java

private void invalidateSession(MessageContext msgContext) {

    // First check for HTTP request
    HttpServletRequest request = (HttpServletRequest) msgContext
            .getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);

    if (request == null) {
        HttpSession session = request.getSession();
        if (session != null) {
            try {
                session.invalidate();
            } catch (IllegalStateException e) {
                log.debug("Unable to invalidate session ", e);
            }//from  www.  j a v a 2s  . c  o  m
        }
    }
    // This could be nhttp transport
    // We do not need to anything to clear sessions
}

From source file:wicket.protocol.http.AbstractHttpSessionStore.java

/**
 * @see wicket.session.ISessionStore#invalidate(Request)
 *//*from   w  w w .  jav  a 2s  . c om*/
public final void invalidate(Request request) {
    WebRequest webRequest = toWebRequest(request);
    HttpSession httpSession = getHttpSession(webRequest);
    if (httpSession != null) {
        try {
            httpSession.invalidate();
        } catch (IllegalStateException e) {
            // Ignore
        }
    }
}

From source file:com.impetus.kwitter.mb.LoginBean.java

public String logOff() {
    HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("You have successfully Logged off"));
    session.invalidate();
    return Constants.OUTCOME_SIGNUP_SUCCESSFUL;
}

From source file:com.mylab.TransmitMailBean.java

protected int loginUser() {

    try {/*from  w  w  w . j  ava 2s . co m*/
        // attempt to login the user
        String OU = "/cardadmin";
        jsp.getCmsObject().loginUser(OU, "xxx17yyy");

        // make sure we have a new session after login for security reasons
        HttpSession session = jsp.getRequest().getSession(false);
        if (session != null) {
            session.invalidate();
        }
        session = jsp.getRequest().getSession(true);

    } catch (CmsException e) {
        // return error code
    } finally {
        // switch back to original project
    }

    return 0;
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.authenticate.BasicAuthenticator.java

@Override
public void recordUserIsLoggedOut() {
    HttpSession session = request.getSession();
    notifyOtherUsersOfLogout(session);
    session.invalidate();
}

From source file:base.util.IDSActor.java

/**
 * Demo.//from w  w w .  j ava  2 s.  c om
 * 
 * @see StdHttpSessionBasedActor#logout(javax.servlet.http.HttpSession )
 */
public void logout(HttpSession session) throws ActorException {
    try {
        System.out.println("######SSOUser logout######");
        session.invalidate();
    } catch (IllegalStateException e) {
        // this can be ignored
    }
}