Example usage for javax.servlet.http HttpSession getAttribute

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

Introduction

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

Prototype

public Object getAttribute(String name);

Source Link

Document

Returns the object bound with the specified name in this session, or null if no object is bound under the name.

Usage

From source file:mx.com.quadrum.contratos.controller.crud.EstatusController.java

@ResponseBody
@RequestMapping(value = "eliminarEstatus", method = RequestMethod.POST)
public String eliminarEstatus(Estatus estatus, BindingResult bindingResult, HttpSession session) {
    if (session.getAttribute("usuario") == null) {
        return SESION_CADUCA;
    }/*from   w ww.  j a  v a 2  s. c  om*/
    return estatusService.eliminar(estatus);
}

From source file:cs544.letmegiveexam.controller.UserController.java

@RequestMapping(value = "/viewProfile", method = RequestMethod.GET)
public String viewprofile(ModelMap model, HttpSession session) {
    if (session.getAttribute("user") != null) {
        model.addAttribute("user", (User) session.getAttribute("user"));

    } else {//from   w  ww.j  a va  2s .  c om
        model.addAttribute("user", new User());
    }
    return "viewProfile";

}

From source file:de.ingrid.interfaces.csw.admin.WelcomeController.java

@RequestMapping(value = "/welcome.html", method = RequestMethod.GET)
public String welcome(final HttpSession session) throws Exception {
    if (session.getAttribute("postCommandObject") == null) {
        session.setAttribute("postCommandObject", new Command());
    }//w w w.j a v  a 2 s.  c  o m
    return "redirect:" + ManageHarvesterController.TEMPLATE_LIST_HARVESTER;
}

From source file:mx.com.quadrum.contratos.controller.crud.EstatusController.java

@ResponseBody
@RequestMapping(value = "agregarEstatus", method = RequestMethod.POST)
public String agregarEstatus(@Valid @ModelAttribute("estatus") Estatus estatus, BindingResult bindingResult,
        HttpSession session) {
    if (session.getAttribute("usuario") == null) {
        return SESION_CADUCA;
    }/*from   w w  w. ja v  a 2s . c o m*/
    if (bindingResult.hasErrors()) {
        return ERROR_DATOS;
    }
    return estatusService.agregar(estatus);
}

From source file:mx.com.quadrum.contratos.controller.crud.EstatusController.java

@ResponseBody
@RequestMapping(value = "editarEstatus", method = RequestMethod.POST)
public String editarEstatus(@Valid @ModelAttribute("estatus") Estatus estatus, BindingResult bindingResult,
        HttpSession session) {
    if (session.getAttribute("usuario") == null) {
        return SESION_CADUCA;
    }/*from w ww . j  av a 2  s  .c o  m*/
    if (bindingResult.hasErrors()) {
        return ERROR_DATOS;
    }
    return estatusService.editar(estatus);
}

From source file:controle.LoginControler.java

@RequestMapping(value = "/login.htm", method = RequestMethod.GET)
public String iniciarLogin(@ModelAttribute("usuario") Usuario login, UsuarioDao dao, HttpSession session) {
    String token = (String) session.getAttribute("token");
    if (token != null && token.equals("aprovado")) {
        return "index";
    }/*from  www . jav  a2  s  .co m*/

    return "login";
}

From source file:de.hybris.telcotrail.storefront.controllers.pages.AbstractLoginPageController.java

protected String getUsernameTryingToLogin(HttpSession session) {
    return (String) session.getAttribute(SPRING_SECURITY_LAST_USERNAME);
}

From source file:edu.chalmers.dat076.moviefinder.controller.LoginController.java

@RequestMapping(value = "/me", method = RequestMethod.GET)
public @ResponseBody User getMe(HttpSession s) {
    return (User) s.getAttribute("user");
}

From source file:com.ibm.gbs.gbs_cai_web.config.AuthInterceptor.java

@Override
public boolean preHandle(HttpServletRequest req, HttpServletResponse res, Object o) throws Exception {
    HttpSession session = req.getSession();

    if (session.getAttribute("user") == null) {
        res.sendRedirect("/login");
        return false;
    }// w w  w . j a va 2  s.c o m

    return true;
}

From source file:mx.com.quadrum.contratos.controller.crud.TipoContratoController.java

@ResponseBody
@RequestMapping(value = "eliminarTipoContrato", method = RequestMethod.POST)
public String eliminarTipoContrato(TipoContrato tipoContrato, BindingResult bindingResult,
        HttpSession session) {
    if (session.getAttribute("usuario") == null) {
        return SESION_CADUCA;
    }/* www .  j a v  a  2 s .  c  o m*/
    return tipoContratoService.eliminar(tipoContrato);
}