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.esd.vs.controller.IndexController.java

/**
 * ?/*from   w  ww  .j  av  a 2s. c  o  m*/
 * 
 * @return
 */
@RequestMapping(value = "/quit", method = RequestMethod.GET)
public ModelAndView quitGet(HttpSession session) {
    session.removeAttribute(Constants.USER_ID);
    return new ModelAndView("login");
}

From source file:com.healthcit.cacure.web.controller.LogoutController.java

@RequestMapping(value = "/logout", method = RequestMethod.GET)
public View processLogout(HttpServletRequest request) {

    HttpSession session = request.getSession();

    try {/*  w  w w . j av a 2 s . c om*/
        session.removeAttribute(Constants.CREDENTIALS);
        session.invalidate();
    } catch (Exception ex) {
        //log exception
        log.error("Error in LogoutAction", ex);
    }

    return new RedirectView(Constants.HOME_URI, true);
}

From source file:com.iterzp.momo.service.impl.RSAServiceImpl.java

@Override
@Transactional(readOnly = true)// ww  w  . j a  v  a2s  . c o  m
public void removePrivateKey(HttpServletRequest request) {
    Assert.notNull(request);
    HttpSession session = request.getSession();
    session.removeAttribute(PRIVATE_KEY_ATTRIBUTE_NAME);
}

From source file:org.jsche.controller.UserController.java

@RequestMapping(value = "/logout")
public String logout(HttpSession session) {
    session.removeAttribute(Constants.LOGIN_USER);
    return "index";
}

From source file:br.com.arduinoweb.controller.UserController.java

@RequestMapping("/Login")
public String Login(HttpSession session, HttpServletResponse response, HttpServletRequest request) {
    session.removeAttribute("usuarioLogado");
    session.removeAttribute("ip");
    session.removeAttribute("porta");
    session.removeAttribute("conexao");
    return "User/Login";
}

From source file:org.iwethey.forums.web.user.LogoutController.java

/**
 * Remove the user name from the session to indicate that
 * the user is no longer logged in.//  w  w w .j  ava2s . c  om
 * <p>
 */
public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    HttpSession sess = request.getSession(false);
    if (sess != null) {
        sess.removeAttribute(USER_ID_ATTRIBUTE);
    }

    return new ModelAndView(new RedirectView("../main.iwt"));
}

From source file:com.greglturnquist.spring.social.ecobee.SimpleSignInAdapter.java

private void removeAuthenticationAttributes(HttpSession session) {

    if (session == null) {
        return;//from   w  w  w.  j a  va2 s .c  o m
    }
    session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
}

From source file:com.lioland.harmony.web.controller.DefaultController.java

@RequestMapping(method = RequestMethod.POST, value = "/authenticate")
public String authenticate(String email, String password, HttpServletRequest request) {
    User user = new User();
    user.setEmail(email);// w  ww .ja v a  2s  . c  o m
    user.loadObject();
    HttpSession session = request.getSession();
    session.removeAttribute(Constants.SESSION_ATTR_USER);
    if (user.getPassword().equals(password)) {
        //            user.setPassword(DigestUtils.sha256Hex(user.getEmail().toLowerCase()));
        session.setAttribute(Constants.SESSION_ATTR_USER, user);
        System.out.println("Authenticated: " + user.getFirstName());
    }
    return "redirect:home";
}

From source file:com.pkrete.locationservice.admin.controller.mvc.EditLanguageController.java

@RequestMapping(method = RequestMethod.POST)
public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response,
        @ModelAttribute("language") Language language, BindingResult result) throws Exception {

    validator.validate(language, result);

    if (result.hasErrors()) {
        return new ModelAndView("edit_language", new ModelMap());
    }//  ww  w  .  j a  va 2 s.  c  o  m

    language.setUpdater(getUser(request).getUsername());
    /* Save language to DB */
    if (!languagesService.update(language)) {
        throw new Exception("Updating language failed.");
    }

    /* Update logged in user */
    HttpSession session = request.getSession();
    session.removeAttribute("user");
    session.setAttribute("user", usersService.getUser(request.getRemoteUser()));
    /* Return to languages page */
    return new ModelAndView(
            "redirect:languages.htm?select_language=" + request.getParameter("select_language"));
}

From source file:com.pkrete.locationservice.admin.controller.mvc.AddLanguageController.java

@RequestMapping(method = RequestMethod.POST)
public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response,
        @ModelAttribute("language") Language language, BindingResult result) throws Exception {
    Owner owner = getOwner(request);
    language.setOwner(owner);/*w w w .  j  a  v a2s. c  o  m*/

    validator.validate(language, result);

    if (result.hasErrors()) {
        return new ModelAndView("add_language", new ModelMap());
    }

    language.setCreator(getUser(request).getUsername());
    /* Save new language to DB */
    if (!languagesService.create(language)) {
        throw new Exception("Creating language failed.");
    }
    /* Does user want to create default templates */
    if (request.getParameter("templates") != null) {
        /* Create default templates. */
        templatesService.createDefaults(language.getCode(), owner);
    }
    /* Update logged in user */
    HttpSession session = request.getSession();
    session.removeAttribute("user");
    session.setAttribute("user", usersService.getUser(request.getRemoteUser()));
    /* Return to languages page */
    return new ModelAndView("redirect:languages.htm");
}