List of usage examples for javax.servlet.http HttpServletRequest isRequestedSessionIdValid
public boolean isRequestedSessionIdValid();
From source file:com.acme.demo.web.LogoutController.java
@RequestMapping(method = RequestMethod.GET) public void logout(HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(false); if (request.isRequestedSessionIdValid() && session != null) { session.invalidate();/*from ww w.j av a 2 s . co m*/ } handleLogOutResponse(request, response); }
From source file:controller.NotificationsController.java
@RequestMapping(value = "notifications", method = RequestMethod.GET) public ModelAndView handleNotifs(HttpServletRequest request) { HttpSession session = request.getSession(); if (session == null || !request.isRequestedSessionIdValid()) { return new ModelAndView("index"); }//from ww w.jav a 2 s . c o m session.setAttribute("currentPage", "/notifications.htm"); // Get all the notifications sent to this user UsersEntity user = (UsersEntity) session.getAttribute("user"); ArrayList<NotificationsEntity> notifs = this.notifsService.searchByTarget(user); ModelAndView mv = new ModelAndView("notifications"); mv.addObject("currentUser", user); mv.addObject("notifs", notifs); mv.addObject("nbNotifs", notifs.size()); return mv; }
From source file:controller.NotificationsController.java
@RequestMapping(value = "{userId}/sendRequest", method = RequestMethod.GET) public ModelAndView handleSendRequest(HttpServletRequest request, @PathVariable Long userId) { HttpSession session = request.getSession(); if (session == null || !request.isRequestedSessionIdValid()) { return new ModelAndView("index"); }/*from w w w.j a v a2s .co m*/ UsersEntity user = (UsersEntity) session.getAttribute("user"); UsersEntity targetUser = this.usersService.find(userId); this.notifsService.add(user, targetUser); return new ModelAndView("redirect:profile.htm"); }
From source file:controller.NotificationsController.java
@RequestMapping(value = "{notifId}/denyFriend", method = RequestMethod.GET) public ModelAndView handleDenyFriend(HttpServletRequest request, @PathVariable Long notifId) { HttpSession session = request.getSession(); if (session == null || !request.isRequestedSessionIdValid()) { return new ModelAndView("index"); }//from www . j a v a 2 s. c o m NotificationsEntity notif = this.notifsService.find(notifId); if (notif != null) { this.notifsService.remove(notif); } return new ModelAndView("redirect:/notifications.htm"); }
From source file:controller.PostsController.java
@RequestMapping(value = "home", method = RequestMethod.GET) public ModelAndView handleHome(HttpServletRequest request) { HttpSession session = request.getSession(); if (session == null || !request.isRequestedSessionIdValid()) { return new ModelAndView("index"); }//w w w.j ava2 s. c o m session.setAttribute("currentPage", "/home.htm"); // Get all the posts sent to this user UsersEntity user = (UsersEntity) session.getAttribute("user"); ArrayList<PostsEntity> posts = this.postsService.searchByTarget(user); // Add the posts sent by this user for (PostsEntity post : this.postsService.searchBySender(user)) { if (!posts.contains(post)) { posts.add(post); } } // Add the posts sent by friends for (UsersEntity friend : user.getFriends()) { for (PostsEntity post : this.postsService.searchBySender(friend)) { if (!posts.contains(post)) { posts.add(post); } } } Collections.sort(posts, Collections.reverseOrder()); ModelAndView mv = new ModelAndView("home"); mv.addObject("currentUser", user); mv.addObject("posts", posts); mv.addObject("nbNotifs", this.notifsService.searchByTarget(user).size()); return mv; }
From source file:controller.NotificationsController.java
@RequestMapping(value = "{notifId}/acceptFriend", method = RequestMethod.GET) public ModelAndView handleAcceptFriend(HttpServletRequest request, @PathVariable Long notifId) { HttpSession session = request.getSession(); if (session == null || !request.isRequestedSessionIdValid()) { return new ModelAndView("index"); }/*from ww w.j a va 2s .c o m*/ UsersEntity user = (UsersEntity) session.getAttribute("user"); NotificationsEntity notif = this.notifsService.find(notifId); if (user.equals(notif.getTarget()) && this.usersService.addFriendship(notif.getSender(), user)) { session.setAttribute("user", user); } this.notifsService.remove(notif); ModelAndView mv = new ModelAndView("redirect:" + session.getAttribute("currentPage")); mv.addObject("currentUser", (UsersEntity) session.getAttribute("user")); return mv; }
From source file:controller.PostsController.java
@RequestMapping(value = "{postId}/removePost", method = RequestMethod.GET) public ModelAndView handleRemovePost(HttpServletRequest request, @PathVariable Long postId) { HttpSession session = request.getSession(); if (session == null || !request.isRequestedSessionIdValid()) { return new ModelAndView("index"); }// w ww. j ava2s . com PostsEntity post = this.postsService.find(postId); if (post != null) { this.postsService.remove(post); } return new ModelAndView("redirect:" + session.getAttribute("currentPage")); }
From source file:controller.PostsController.java
@RequestMapping(value = "{userId}/createPost", method = RequestMethod.POST, params = "postContent") public ModelAndView handleAddPost(HttpServletRequest request, @PathVariable Long userId) { HttpSession session = request.getSession(); if (session == null || !request.isRequestedSessionIdValid()) { return new ModelAndView("index"); }/* w w w. jav a2s . c om*/ String content = request.getParameter("postContent"); if (!content.isEmpty()) { UsersEntity sender = (UsersEntity) session.getAttribute("user"); UsersEntity target = this.usersService.find(userId); this.postsService.add(content, sender, target); } return new ModelAndView("redirect:" + session.getAttribute("currentPage")); }
From source file:it.govpay.web.filters.SessionTimeoutFilter.java
private boolean isSessionInvalid(HttpServletRequest httpServletRequest) { boolean sessionInValid = (httpServletRequest.getRequestedSessionId() != null) && !httpServletRequest.isRequestedSessionIdValid(); return sessionInValid; }
From source file:com.gs.config.CustomFilterLogin.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { Assert.isInstanceOf(HttpServletRequest.class, request, "Can only process HttpServletRequest"); Assert.isInstanceOf(HttpServletResponse.class, response, "Can only process HttpServletResponse"); HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; // System.out.println("ESTOY EN CUSTOMFILTERLOGIN: "+httpRequest.getServletPath()); String path = httpRequest.getServletPath(); HttpSession session = httpRequest.getSession(false); if (session == null && !httpRequest.isRequestedSessionIdValid()) { String targetUrl = httpRequest.getContextPath() + "/login"; httpResponse.sendRedirect(httpResponse.encodeRedirectURL(targetUrl)); return;/*from ww w. j a v a 2 s .c om*/ } chain.doFilter(request, response); }