List of usage examples for javax.servlet.http HttpSession getAttribute
public Object getAttribute(String name);
null
if no object is bound under the name. From source file:com.starr.smartbuilds.controller.RegController.java
@RequestMapping(method = { RequestMethod.POST }) public String regUser(@ModelAttribute("user") User user, Model model, HttpServletRequest req, HttpServletResponse resp) throws IOException, ParseException { HttpSession session = req.getSession(); User userr = (User) session.getAttribute("user"); if (userr == null) { model.addAttribute("authMsg", "<a href='./auth'>Log in</a>"); model.addAttribute("exitReg", "<a href='./reg'>Register</a>"); } else {// www .ja va 2 s . c om resp.sendRedirect("./"); } String regMsg = regService.registerUser(user); model.addAttribute("user", new User()); model.addAttribute("result", regMsg); return "register"; }
From source file:echec.controller.PartieController.java
@RequestMapping(value = "/cree_partie", method = RequestMethod.POST) public String creePartie(@ModelAttribute("PartieAttribut") Partie partie, HttpSession s) { Long joueur = (long) s.getAttribute("idUser"); partie.setBlanc(serviceJoueur.findOne(joueur)); partie.setEtat(Partie.Etat.Creer);/* w ww . j a v a2s . c om*/ servicePartie.save(partie); return "redirect:/dashboard"; }
From source file:edu.pitt.sis.infsci2730.finalProject.web.shoppingBagController.java
@RequestMapping(value = "", method = RequestMethod.GET) public ModelAndView mypage(HttpSession session) { try {/*from w w w. j a v a2 s . c o m*/ CustomerDBModel customer = (CustomerDBModel) session.getAttribute("customer"); if (customer == null) { return new ModelAndView("index"); } else { return new ModelAndView("shoppingBag", "customer", customer); } } catch (Exception ex) { Logger.getLogger(OrderHistoryController.class.getName()).log(Level.SEVERE, null, ex); return new ModelAndView("500"); } }
From source file:mx.com.quadrum.contratos.controller.crud.CatalogosController.java
@RequestMapping(value = "catalogo", method = RequestMethod.GET) public String tipoContrato(Model model, HttpSession session) { Usuario usuario = (Usuario) session.getAttribute(USUARIO); List<Permiso> permisos = (List<Permiso>) session.getAttribute(PERMISOS); if (usuario == null || permisos == null) { return "templates/index"; }/*from w w w .j a v a 2 s . com*/ if (usuario.getEsAdmin()) { model.addAttribute("esAdmin", "esAdmin"); } if (usuarioService.tienePermiso(usuario, "catalogo")) { return "templates/noAutorizado"; } model.addAttribute("permisos", permisos); model.addAttribute("estatus", estatusService.buscarTodos()); model.addAttribute("grado", gradoService.buscarTodos()); model.addAttribute("tipoContratos", tipoContratoService.buscarTodos()); model.addAttribute("tipocontrato", new TipoContrato()); return "crud/catalogo"; }
From source file:net.anthonychaves.bookmarks.web.TagController.java
@RequestMapping(method = RequestMethod.GET) public String getBookmarksWithTag(@RequestParam(value = "tag") String tag, HttpSession session, ModelMap model) {// ww w. jav a2 s . co m User user = (User) session.getAttribute("user"); List<BookmarkDetail> bookmarks = tagService.findBookmarksByTag(tag, user); List<String> suggestedTags = tagService.findRelatedTags(tag); model.clear(); model.addAttribute("bookmarks", bookmarks); return "tags"; }
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"); }/*from w ww .j a v a2 s.co m*/ if (currentSeller != null) { session.removeAttribute("currentSeller"); } return "redirect:/"; }
From source file:com.havoc.hotel.admin.controller.CheckinController.java
@RequestMapping(method = RequestMethod.GET, value = "/logout") public String Logout(HttpServletRequest req, HttpServletResponse resp) { HttpSession session = req.getSession(false); String checking = (String) session.getAttribute("username"); if (checking == null) { return "redirect:/?logout=false"; } else {// ww w . ja v a 2s . c om session.invalidate(); return "redirect:/admin"; } }
From source file:io.github.benas.todolist.web.servlet.user.account.DeleteAccountServlet.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); User user = (User) session.getAttribute(TodoListUtils.SESSION_USER); userService.remove(user);/*from ww w . ja va 2s . com*/ session.invalidate(); request.getRequestDispatcher("/index").forward(request, response); }
From source file:mx.com.quadrum.contratos.controller.crud.ContratoController.java
@ResponseBody @RequestMapping(value = "eliminarContrato", method = RequestMethod.POST) public String eliminarContrato(Contrato contrato, BindingResult bindingResult, HttpSession session) { if (session.getAttribute("usuario") == null) { return SESION_CADUCA; }//from ww w.j a v a 2 s .com return contratoService.eliminar(contrato); }
From source file:com.cloudbees.demo.beesshop.cart.ShoppingCartRepository.java
@Nonnull public ShoppingCart getCurrentShoppingCart(@Nonnull HttpServletRequest request) { HttpSession session = request.getSession(); ShoppingCart shoppingCart = (ShoppingCart) session.getAttribute(ShoppingCart.class.getName()); if (shoppingCart == null) { shoppingCart = new ShoppingCart(); session.setAttribute(ShoppingCart.class.getName(), shoppingCart); }//from w w w. j av a 2 s . co m return shoppingCart; }