我做了一个过滤器,目的是想判断如果session过期的话,就直接转到登陆页面index.jsp,我这个系统用到了框架,这个是我的main.jsp
以下是代码
.......
<frameset rows="81,*" cols="*" frameborder="no" border="0" framespacing="0">
  <frame src="top.jsp" name="topFrame" scrolling="NO" noresize >  <frameset id="frame_bottom" cols="0,*" rows="*"  framespacing="0" frameborder="NO" border="0">
    <frame src="left.jsp" name="leftFrame" scrolling="no" noresize>
    <frameset rows="*,21" cols="*" framespacing="0" frameborder="NO" border="0">
      <frame src="right.htm" name="mainFrame">
      <frame src="bottom.htm" name="bottomFrame" scrolling="NO" noresize>
    </frameset>
  </frameset>
</frameset><noframes><body></body></noframes>
</html>
其中的top.jsp有一些链接,点相应的链接调各自的action到对应的页,完成对应的功能。
但是现在的问题就出在这,如果我现在的session过期了,点了链接以后登陆页跑到mainFrame里了,而不是全页显示,不知道这个问题大家是否遇到过,出现了在mainFrame里登陆的效果,显然这不是我想要的,我希望如果session过期了,点这些链接是在整个窗口里显示登陆页面,而不是在mainFrame里显示。下面是我做的那个判断session是否过期的过滤器。
public class IsSessionValidFilter implements Filter {
.........
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest httprequest = ((HttpServletRequest) request);
HttpServletResponse httpresponse = (HttpServletResponse) response;
if (request instanceof HttpServletRequest) {
String performerId = (String) httprequest.getSession()
.getAttribute("performerId");
if (performerId == null
&& !httprequest.getServletPath().equals("/login.do")) {
httpresponse.sendRedirect(httprequest.getContextPath()
+ "/index.jsp");
                                    //这里好象不能指定target吧,如果能指定就好办了。。
return;
}
}
chain.doFilter(request, response);
}
}
其实163邮箱也存在这个问题,如果session过期,它也是将登陆页面给你链接到了frame里边。
不知道大家是否也遇到同样的困惑