在框架网页中当session过期后,如何强制调用login.jsp进行登陆

环境:
win2k+tomcat5.5.17+jdk1.5+MyEclipse5.0M2
问题内容:
现在有一个框架的网页,有顶部,左部和main窗口组成,框架网页的代码如下:
<frameset rows="110,*" Border="0" bordercolor="#6e3953">
<frame name="banner" scrolling="no" noresize target="contents" src="top.htm">
<frameset cols="189,83%">
<frame name="contents" target="main" src="left.jsp">
<frame name="main" src="main.htm">
</frameset>
<noframes>
我得问题是:
系统的所有内容都需要通过tomcat安全域的验证,安全域的验证通过login.jsp,验证成功后,将当前的用户保存到session中,然后可以访问系统的内容,现在验证成功了,过了20分钟后,session过期
,然后我点击了网页上的一个连接,系统自动调用的login.jsp,不过此jsp文档在框架窗口的main窗口中打开的,而我希望,这时候应当直接出现login.jsp,而不是在main窗口中打开,这样的技巧应当如何做
[699 byte] By [xkwth-王廷华] at [2008-1-6]
# 1
每个页面添加session.jsp用于判断session是否过期,过期则进行重定向
zhangj0571-笨鸟飞飞 at 2007-10-25 > top of Msdn China Tech,Java,Web 开发...
# 2
最好实现一个servlet监听器,判断一下.
xfxf521-天使也一样 at 2007-10-25 > top of Msdn China Tech,Java,Web 开发...
# 3
登陆的时候把登陆信息封装后保存在session里,在每个文件包含一个判断用户是否登陆的jsp文件
# 4
Add one filter in web.xml, in this filter you can control the page flow.
kenees-飞跃巅峰 at 2007-10-25 > top of Msdn China Tech,Java,Web 开发...
# 5
kenees(飞跃巅峰)你好,这种情况如何在web.xml中加filter呢,能否说的详细点,谢谢
xkwth-王廷华 at 2007-10-25 > top of Msdn China Tech,Java,Web 开发...
# 6
写过滤器就可以了阿!只要你session=null就过滤自动跳到登陆页面!!!
whzresponse at 2007-10-25 > top of Msdn China Tech,Java,Web 开发...
# 7
用filter,是最简单的方式。。。
qiyadeng-。。。。。 at 2007-10-25 > top of Msdn China Tech,Java,Web 开发...
# 8
xkwth(王廷华) ( ) 信誉:99 Blog 2006-09-11 11:39:00 得分: 0

kenees(飞跃巅峰)你好,这种情况如何在web.xml中加filter呢,能否说的详细点,谢谢

please do google
kenees-飞跃巅峰 at 2007-10-25 > top of Msdn China Tech,Java,Web 开发...
# 9
<script>
top.location.href ="login.jsp" //框架的最顶层窗口地址定向到login.jsp
</script>

ftiger-哈哈鱼 at 2007-10-25 > top of Msdn China Tech,Java,Web 开发...
# 10
谢谢各位,能否说的明白点呢
xkwth-王廷华 at 2007-10-25 > top of Msdn China Tech,Java,Web 开发...
# 11
filter的功能知道,google下servlet filter
qiyadeng-。。。。。 at 2007-10-25 > top of Msdn China Tech,Java,Web 开发...
# 12
package bookstore.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class LoginCheckFilter
extends HttpServlet implements Filter
{
private FilterConfig filterConfig;
//Handle the passed-in FilterConfig
public void init(FilterConfig filterConfig)
throws ServletException
{
this.filterConfig = filterConfig;
}

//Process the request/response pair
public void doFilter(ServletRequest request, ServletResponse response
, FilterChain filterChain)
{
try
{
//进行请求和响应的类型转换
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;

boolean isValid = true;
String uriStr = httpRequest.getRequestURI().toUpperCase();

if (uriStr.indexOf("LOGIN.JSP") == -1 &&
uriStr.indexOf("SWITCH.JSP") == -1 &&
httpRequest.getSession().getAttribute("ses_userBean") == null)
{
isValid = false;
}
if (isValid)
{
filterChain.doFilter(request, response);
} else
{
httpResponse.sendRedirect("/webModule/login.jsp");
}
} catch (ServletException sx)
{
filterConfig.getServletContext().log(sx.getMessage());
} catch (IOException iox)
{
filterConfig.getServletContext().log(iox.getMessage());
}
}

//Clean up resources
public void destroy()
{
}
}

MSN:yz_wzl@hotmail.com
wuzonglai-心雨 at 2007-10-25 > top of Msdn China Tech,Java,Web 开发...
# 13
?
<script>
top.location.href ="login.jsp" //框架的最顶层窗口地址定向到login.jsp
</script>
human_2-风一帆 at 2007-10-25 > top of Msdn China Tech,Java,Web 开发...
# 14
String uid=(String)session.getValue("userid");
if(uid==null){
out.print("<script>parent.window.location='/login.jsp';</script>");
}
anchor1-聪头 at 2007-10-25 > top of Msdn China Tech,Java,Web 开发...
# 15
LS好样的!只有你才明白LZ的意思
jordanboss-jing at 2007-10-25 > top of Msdn China Tech,Java,Web 开发...
# 16
每个页面加一个IF语句判断session是否为空,是比较好的方法
# 17
ding
# 18
parent.window.location
没试过在多层框架下能不能到IE的最顶部窗口??
ftiger-哈哈鱼 at 2007-10-25 > top of Msdn China Tech,Java,Web 开发...