使用frameset,怎么在session,timeout后,点击任何链接都能整体返回index页面

项目中遇到这个问题:session-timeout后,操作左菜单原来页面,会弹出一个新的登录页面在target=“NT_PHVIEW”,而不是,一个新的整体登录页面,

 

解决方案:

         在我自定义的SessionFilter里加了这么一段代码:

  

package com.alu.gm.filter;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.*;
import javax.servlet.http.*;

import com.alu.gm.util.LdapUtil;

public class SessionFilter implements Filter
{
  public void init(FilterConfig fConfig) throws ServletException { }
 
  public void doFilter(ServletRequest req, ServletResponse res, FilterChain fChain) throws IOException, ServletException
  {
    HttpServletRequest  request     = (HttpServletRequest)req;
    HttpServletResponse response    = (HttpServletResponse)res;
    String              uri         = request.getRequestURI();
    String              contextPath = request.getContextPath();
    if (!uri.equals(contextPath+"/index.jsp")
     && !uri.equals(contextPath+"/LoginServlet")
     && !uri.equals(contextPath+"/LogoutServlet")
     && !uri.equals(contextPath+"/images/logo_alcatel-lucent-2lines.gif"))
    {
      HttpSession session = request.getSession(false);
      if (session == null || session.getAttribute(LdapUtil.LOGIN_PERSON) == null)  // Check if it has passed validation
      {
        clearCache(response);           // Clear cache before forwarding
//      request.getRequestDispatcher("/index.jsp").forward(request, response);
        PrintWriter out=res.getWriter();
        out.println("<script>");
        out.println("window.top.location.href='index.jsp';");
        out.println("</script>");
        return;
      }
    }
    fChain.doFilter(req, res);
  }
  /** Clear cache for client browser */
  public void clearCache(HttpServletResponse response)
  {
    response.setHeader("Pragma","No-cache");
    response.setHeader("Cache-Control","no-cache");  
    response.setDateHeader("Expires", -10);
  }
 
  public void destroy() { }

}

 

 

附网上资料:

关于js中window.location.href,location.href,parent.location.href,top.location.href的用法
"window.location.href"、"location.href"是本页面跳转.
"parent.location.href" 是上一层页面跳转.
"top.location.href" 是最外层的页面跳转.
举例说明:
    如果A,B,C,D都是html,D是C的iframe,C是B的iframe,B是A的iframe,如果D中js这样写
    "window.location.href"、"location.href":D页面跳转
    "parent.location.href":C页面跳转
    "top.location.href":A页面跳转
如果D页面中有form的话,
    <form>:  form提交后D页面跳转
    <form target="_blank">:  form提交后弹出新页面
    <form target="_parent">:  form提交后C页面跳转
    <form target="_top"> :  form提交后A页面跳转

如果访问的是iframe里面的页面,重新加载最外层的页面
< html >
< head >
< title ></ title >
< script  language ="javascript" >
function  escapeFrame(){
      
if  (window.top.location.href  !=  window.location.href) {
        window.top.location.reload();
      }
}
</ script >
</ head >

< body  onload ="escapeFrame()" >
< iframe  src ="b.html"   ></ iframe >
</ body >
</ html >

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

[shenhonglei]

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值