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.sun.socialsite.web.filters.SessionFilter.java
/** * *///from w ww . j a v a 2s. c o m public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpReq = (HttpServletRequest) req; String remoteUser = httpReq.getRemoteUser(); if (remoteUser != null) { HttpSession httpSession = httpReq.getSession(); if (httpSession.getAttribute(REMOTE_USER) == null) { log.debug( String.format("Setting REMOTE_USER=%s on Session[id=%s]", remoteUser, httpSession.getId())); httpSession.setAttribute(REMOTE_USER, remoteUser); } assert (httpSession.equals(SessionListener.getSession(httpSession.getId()))); } chain.doFilter(req, resp); }
From source file:bc8.movies.controllers.LoginController.java
@RequestMapping(value = "/editUser") public ModelAndView editUser(String user, HttpSession session) { ModelAndView mv = new ModelAndView("editUser"); if (session.getAttribute("user") == null) { mv.setViewName("redirect:/home"); }// w w w. j ava2s . c o m return mv; }
From source file:com.MyHistory.Controller.UsuarioController.java
@RequestMapping(value = "/home", method = RequestMethod.GET) public ModelAndView cargarHome(HttpServletRequest pRequest) { System.out.println("Pasando por indexController method:GET"); ModelAndView model = new ModelAndView("home"); HttpSession session = pRequest.getSession(); UsuarioView usuario = (UsuarioView) session.getAttribute("Usuario"); if (usuario == null) { model.setViewName("redirect:/login.htm"); return model; }/*from ww w .j a v a2s. co m*/ model.addObject("user", usuario); return model; }
From source file:com.eftech.wood.controllers.ControllerCartPhone.java
@RequestMapping("/add-product-to-customer-basket") public String addProductToShoppingCart(@RequestParam(value = "id") int id, HttpSession session) { ShoppingCart cart = (ShoppingCart) session.getAttribute("cart"); if (cart == null) cart = new ShoppingCart(); // Iphone iphone = iphoneJDBCTemplate.getIphone(id); // ShopProduct prod = iphone; // cart.addItem(prod); session.setAttribute("cart", cart); String page;//from w ww. j a v a2 s. c o m try { page = (String) session.getAttribute("page"); } catch (Exception e) { page = "index"; } return "redirect:/" + page + ".htm"; }
From source file:miage.ecom.web.controller.CartController.java
@RequestMapping(value = "/cart") public String index(Model model, HttpSession session) { CartBean cart;//from w w w . j a va 2s . c o m if (session.getAttribute("cart") == null) { cart = new CartBean(); } else { cart = (CartBean) session.getAttribute("cart"); session.setAttribute("cart", cart); } List<Purchase> cartContents = ecomBeanFrontLocal.getCartContents(cart); model.addAttribute("cartTotalValue", ecomBeanFrontLocal.getTotalValue(cart)); model.addAttribute("nbProducts", ecomBeanFrontLocal.getCartContents(cart).size()); model.addAttribute("products", cartContents); return "cart"; }
From source file:mx.com.quadrum.contratos.controller.HomeController.java
@RequestMapping(value = "/") public String homeController(HttpSession session, Model model) { Usuario u = (Usuario) session.getAttribute(USUARIO); if (u != null) { if (u.getEsAdmin()) { model.addAttribute("esAdmin", "esAdmin"); }// ww w. j av a2 s . c o m model.addAttribute("nombre", u.getNombres() + " " + u.getPaterno() + " " + u.getMaterno()); return "templates/inicio"; } return "templates/index"; }
From source file:pivotal.au.se.gemfirexdweb.controller.ConmapController.java
@RequestMapping(value = "/viewconmap", method = RequestMethod.GET) public String worksheet(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {//from ww w.j ava 2s . co m Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to show connection map"); ConnectionManager cm = ConnectionManager.getInstance(); String conMapAction = request.getParameter("conMapAction"); String key = request.getParameter("key"); logger.debug("conMapAction = " + conMapAction); logger.debug("key = " + key); if (conMapAction != null) { if (conMapAction.equalsIgnoreCase("DELETE")) { // remove this connection from Map and close it. cm.removeConnection(key); logger.debug("Connection closed for key " + key); model.addAttribute("saved", "Successfully closed connection with key " + key); } } model.addAttribute("conmap", cm.getConnectionMap()); model.addAttribute("conmapsize", cm.getConnectionListSize()); // This will resolve to /WEB-INF/jsp/conmap.jsp return "conmap"; }
From source file:com.iterzp.momo.service.impl.RSAServiceImpl.java
@Override @Transactional(readOnly = true)/*from w w w. j a va 2 s . co m*/ public String decryptParameter(String name, HttpServletRequest request) { Assert.notNull(request); if (name != null) { HttpSession session = request.getSession(); RSAPrivateKey privateKey = (RSAPrivateKey) session.getAttribute(PRIVATE_KEY_ATTRIBUTE_NAME); String parameter = request.getParameter(name); if (privateKey != null && StringUtils.isNotEmpty(parameter)) { return RSAUtils.decrypt(privateKey, parameter); } } return null; }
From source file:io.github.benas.todolist.web.servlet.user.HomeServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); User user = (User) session.getAttribute(TodoListUtils.SESSION_USER); List<Todo> todoList = todoService.getTodoListByUser(user.getId()); //todo list is request scoped to avoid storing and synchronizing it in session for each CRUD operation request.setAttribute("todoList", todoList); request.setAttribute("homeTabStyle", "active"); int totalCount = todoList.size(); int doneCount = TodoListUtils.countTotalDone(todoList); int todoCount = totalCount - doneCount; request.setAttribute("totalCount", totalCount); request.setAttribute("doneCount", doneCount); request.setAttribute("todoCount", todoCount); request.getRequestDispatcher(HOME_PAGE).forward(request, response); }
From source file:org.hspconsortium.platform.authorization.web.LaunchContextFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { HttpSession session = request.getSession(); try {//from w ww.j a v a 2 s . co m Set<String> launchContextIds = (Set<String>) session.getAttribute(Constants.LAUNCH_CONTEXT_ID_MAP_KEY); LaunchContextHolder.setLaunchContextIds(launchContextIds); filterChain.doFilter(request, response); } finally { session.setAttribute(Constants.LAUNCH_CONTEXT_ID_MAP_KEY, LaunchContextHolder.getLaunchContextIds()); LaunchContextHolder.clearLaunchContextIds(); } }