×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Nhan Tran
Added: Aug 7, 2021 1:05 PM
Views: 3673
Tags: no tags
  1.  HttpServletRequest req = (HttpServletRequest) request;
  2.         HttpServletResponse res = (HttpServletResponse) response;
  3.         String uri = req.getRequestURI();
  4.         HttpSession session = req.getSession();
  5.         if (session.getAttribute("user") == null && !uri.endsWith("css") && !uri.contains("login") && !uri.contains("Login")) {
  6.             res.sendRedirect(LOGIN);
  7.             return;
  8.         } else {
  9.             chain.doFilter(request, response);
  10.         }