首页 > 技术文章 > session过期返回登录页面跳出frame

c9999 2016-06-21 09:51 原文

session 过期返回登录页面

方法1,

HttpSession session = request.getSession();
      String LOGIN_ID = (String) session.getAttribute("LOGIN_ID");
      if (null == LOGIN_ID||"".equals(LOGIN_ID)) {
          java.io.PrintWriter out = response.getWriter();  
          out.println("<html>");  
          out.println("<script>");  
   out.println("window.open ('"+request.getContextPath()+"/login.jsp','_top')");  
           out.println("</script>");  
           out.println("</html>");  
           return;
                

方法2.

在login.jsp中加入

 <script>
        if(window.top!==window.self){window.top.location=window.location};
 </script>

 

推荐阅读