session过期返回登录页面跳出frame

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>

 

posted @ 2016-06-21 09:51  咸鱼Boy  阅读(2659)  评论(0编辑  收藏  举报