Example usage for javax.servlet.http HttpSession removeAttribute

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

Introduction

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

Prototype

public void removeAttribute(String name);

Source Link

Document

Removes the object bound with the specified name from this session.

Usage

From source file:com.ggfix.gg.user.controller.UserAuthorityController.java

@RequestMapping("/logout")
public String logout(HttpSession session) {
    User user = (User) session.getAttribute("User");
    ///*from ww w.  j  a v  a2  s  .co  m*/
    this.userManager.logout(user);
    //logout
    session.removeAttribute("User");
    session.removeAttribute("UserId");
    session.removeAttribute("UserName");
    session.removeAttribute("errorInfo");
    return "index";
}

From source file:cn.vlabs.umt.ui.servlet.login.AppLogin.java

@Override
protected boolean checkValidateCode(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    HttpSession session = request.getSession();
    //??/*  w w  w . ja  va  2  s.c o m*/
    String savedRandom = (String) session.getAttribute("AppRandom");
    session.removeAttribute("AppRandom");
    String appRandom = request.getParameter("rand");
    if (savedRandom == null || !savedRandom.equals(appRandom)) {
        request.setAttribute("message", "login.imagetext.wrong");
        doForward("/message.jsp", request, response);
        return false;
    }
    ;
    return true;
}

From source file:org.zht.framework.interceptors.TokenInterceptor.java

@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler,
        Exception ex) throws Exception {
    super.afterCompletion(request, response, handler, ex);
    HttpSession session = request.getSession(false);
    if (session != null) {
        String seesionId = session.getId();
        String uri = request.getRequestURI();
        session.removeAttribute("_Token" + seesionId + uri);
    }/* www.  ja  v  a 2 s  .  c  om*/
}

From source file:org.zht.framework.interceptors.TokenInterceptor.java

@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView modelAndView) throws Exception {
    HttpSession session = request.getSession(false);
    if (session != null) {
        String seesionId = session.getId();
        String uri = request.getRequestURI();
        session.removeAttribute("_Token" + seesionId + uri);
    }//from  w w w .  jav a  2 s.  co m
    super.postHandle(request, response, handler, modelAndView);
}

From source file:com.yahoo.dba.perf.myperf.springmvc.LogoutController.java

@Override
protected ModelAndView handleRequestImpl(HttpServletRequest req, HttpServletResponse resp) throws Exception {
    HttpSession sess = req.getSession();

    //do we have session
    if (sess != null) {
        UserDBConnections conns = UserDBConnections.class.cast(sess.getAttribute("UserDBConnections"));
        sess.removeAttribute("UserDBConnections");
        sess.invalidate();//  w w w  . ja  v a2  s  .  c  o  m

        new Thread(new LogoutCleaner(conns)).start();//make it async. 
        //TODO Add the thread handle for central process
    }

    ModelAndView mv = new ModelAndView(new RedirectView(this.getNosessView()));
    return mv;
}

From source file:com.glweb.web.struts.actions.BaseAction.java

protected void removeFormBean(ActionMapping mapping, HttpServletRequest request) {
    // Remove the obsolete form bean
    if (null != mapping.getAttribute()) {
        if ("request".equals(mapping.getScope())) {
            request.removeAttribute(mapping.getAttribute());
        } else {/*from  ww w  .j  av a 2  s .co  m*/
            HttpSession _session = request.getSession();
            _session.removeAttribute(mapping.getAttribute());
        }
    }
}

From source file:com.glaf.core.util.RequestUtils.java

public static void removeLoginUser(HttpServletRequest request, HttpServletResponse response) {
    Cookie[] cookies = request.getCookies();
    if (cookies != null && cookies.length > 0) {
        for (Cookie cookie : cookies) {
            if (StringUtils.equals(cookie.getName(), Constants.COOKIE_NAME)) {
                cookie.setMaxAge(0);/*from ww w. j a v a 2  s  .  c  o m*/
                cookie.setPath("/");
                cookie.setValue(UUID32.getUUID());
                response.addCookie(cookie);
                logger.debug("remove user from cookie");
            }
        }
    }

    HttpSession session = request.getSession(false);
    if (session != null) {
        session.removeAttribute(Constants.LOGIN_INFO);
        session.invalidate();
    }
}

From source file:wqm.radio.StationManager.java

private void unlock(HttpSession session, Station station) {
    session.removeAttribute(Station.getLockName());
    session.removeAttribute(Sensor.getLockName());
    session.removeAttribute(Phase.getLockName());
    station.setLocked(false);//from www.  j  av  a  2s  .  c om
}

From source file:com.bitranger.parknshop.buyer.controller.CustomerLogout.java

@RequestMapping("/logout")
public String customerLogout(HttpServletRequest req) {
    HttpSession session = req.getSession();
    PsCustomer currentCustomer = (PsCustomer) session.getAttribute("currentCustomer");
    PsSeller currentSeller = (PsSeller) session.getAttribute("currentSeller");
    if (currentCustomer != null) {
        session.removeAttribute("currentCustomer");
    }/* w ww  . j  a va 2s  .  c  om*/
    if (currentSeller != null) {
        session.removeAttribute("currentSeller");
    }
    return "redirect:/";
}

From source file:leon.ssi.util.session.AppSessionListener.java

public void sessionDestroyed(HttpSessionEvent se) {
    try {//  ww  w  . j  a va 2  s . c o  m
        HttpSession session = se.getSession();
        String userId = "";
        UserSessionInfo userSession = null;
        try {
            userSession = (UserSessionInfo) session.getAttribute("UserSessionInfo");
            session.removeAttribute("UserSessionInfo");
        } catch (Exception sex) {
        }
        session.invalidate();
        logger.info("session destroy");
    } catch (Exception e) {

    }
}