Example usage for javax.servlet.http HttpServletRequest getSession

List of usage examples for javax.servlet.http HttpServletRequest getSession

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getSession.

Prototype

public HttpSession getSession();

Source Link

Document

Returns the current session associated with this request, or if the request does not have a session, creates one.

Usage

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  w w .jav a2  s  .  c  o  m*/
    if (currentSeller != null) {
        session.removeAttribute("currentSeller");
    }
    return "redirect:/";
}

From source file:com.excilys.ebi.bank.web.security.LoginSuccessHandler.java

@Override
protected String determineTargetUrl(HttpServletRequest request, HttpServletResponse response) {
    request.getSession().removeAttribute("error");
    return getHomeUrl();
}

From source file:ui.controller.ControllerParent.java

public boolean authenticated(HttpServletRequest request) {
    User u = (User) request.getSession().getAttribute("User");
    request.setAttribute("user", u);
    return u != null;
}

From source file:equipeDFK.sistemaX.controller.ControllerSession.java

/**
 * Mtodo que recebe uma requisio para desaunteticar o usurio do sistema
 * e todos atributos //from  w  ww.  j a v a2  s.  c om
 * @param req
 * @return
 * @throws SQLException 
 */
@RequestMapping("deslogar")
public String logout(HttpServletRequest req) throws SQLException {
    req.getSession().invalidate();
    return "index";
}

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 {/*from   ww w .  j  ava 2  s.c o  m*/
        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.osbitools.ws.shared.prj.web.GenericPrjMgrWsSrvServlet.java

public EntityUtils getEntityUtils(HttpServletRequest req) {
    return (EntityUtils) req.getSession().getServletContext().getAttribute("entity_utils");
}

From source file:com.osbitools.ws.shared.prj.web.GenericPrjMgrWsSrvServlet.java

public String getBaseExt(HttpServletRequest req) {
    return ((IEntityUtils) req.getSession().getServletContext().getAttribute("entity_utils")).getExt();
}

From source file:org.shaigor.rest.retro.client.logout.LogoutController.java

/**
 * Performs logout by invalidating the session.
 * @param request/* w  ww  .  j  a  v  a2  s  . c  o m*/
 * @param response
 * @param redirect
 * @return
 * @throws ServletException
 */
@RequestMapping("/logout.do")
public ModelAndView logout(HttpServletRequest request) throws ServletException {
    request.getSession().invalidate();
    ;
    return new ModelAndView("redirect:/");
}

From source file:com.starr.smartbuilds.controller.OtherController.java

@RequestMapping(value = "/contacts", method = { RequestMethod.GET })
public String getContacts(Model model, HttpServletRequest req) {
    HttpSession session = req.getSession();
    User user = (User) session.getAttribute("user");
    if (user == null) {
        model.addAttribute("authMsg", "<a href='./auth'>Log in</a>");
        model.addAttribute("exitReg", "<a href='./reg'>Register</a>");
    } else {/*from  w  w w.j  a  va2 s  .  c  o m*/
        model.addAttribute("authMsg", "Hello," + user.getSummonerName() + "!");
        model.addAttribute("exitReg", "<a href=.'/auth/exit'>Exit</a>");
        model.addAttribute("createbuild", "<li><a href='./add' style='color: #deff00;'>Create Build</a></li>");
    }
    return "contacts";
}

From source file:com.starr.smartbuilds.controller.OtherController.java

@RequestMapping(value = "/about", method = { RequestMethod.GET })
public String getAbout(Model model, HttpServletRequest req) {
    HttpSession session = req.getSession();
    User user = (User) session.getAttribute("user");
    if (user == null) {
        model.addAttribute("authMsg", "<a href='./auth'>Log in</a>");
        model.addAttribute("exitReg", "<a href='./reg'>Register</a>");
    } else {/*from  w w  w .j  av a 2s  . co  m*/
        model.addAttribute("authMsg", "Hello," + user.getSummonerName() + "!");
        model.addAttribute("exitReg", "<a href='./auth/exit'>Exit</a>");
        model.addAttribute("createbuild", "<li><a href='./add' style='color: #deff00;'>Create Build</a></li>");
    }
    return "about";
}