站内搜索: 请输入搜索关键词

当前页面: 开发资料首页JSP 专题使用过滤器验证session是否过期,过期就链到登陆页,现在链到了frame里边,在线等。。。。

使用过滤器验证session是否过期,过期就链到登陆页,现在链到了frame里边,在线等。。。。

摘要: 使用过滤器验证session是否过期,过期就链到登陆页,现在链到了frame里边,在线等。。。。


我做了一个过滤器,目的是想判断如果session过期的话,就直接转到登陆页面index.jsp,我这个系统用到了框架,这个是我的main.jsp
以下是代码
.......












&lt;body&gt;<br/><br/>&lt;/body&gt;

其中的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里边。
不知道大家是否也遇到同样的困惑。。。


index.jsp 加这段代码
<script language="javascript">
if (top.location !== self.location) {
top.location=self.location;
}
</script>

谢谢


↑返回目录
前一篇: jsp显示中文问题
后一篇: 求助 ,B/S结构,能不能实现文件的批量导入?????