环境:
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窗口中打开,这样的技巧应当如何做

解决方案 »

  1.   

    每个页面添加session.jsp用于判断session是否过期,过期则进行重定向
      

  2.   

    最好实现一个servlet监听器,判断一下.
      

  3.   

    登陆的时候把登陆信息封装后保存在session里,在每个文件包含一个判断用户是否登陆的jsp文件
      

  4.   

    Add one filter in web.xml, in this filter you can control the page flow.
      

  5.   

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

  6.   

    写过滤器就可以了阿!!只要你session=null就过滤自动跳到登陆页面!!!!!
      

  7.   

    xkwth(王廷华) ( ) 信誉:99    Blog  2006-09-11 11:39:00  得分: 0  
     
     
       kenees(飞跃巅峰)你好,这种情况如何在web.xml中加filter呢,能否说的详细点,谢谢
      
     
    please do google
      

  8.   

    <script>
    top.location.href ="login.jsp" //框架的最顶层窗口地址定向到login.jsp
    </script>
      

  9.   

    filter的功能知道,google下servlet filter
      

  10.   

    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:[email protected]
      

  11.   


    <script>
    top.location.href ="login.jsp" //框架的最顶层窗口地址定向到login.jsp
    </script>
      

  12.   

    String uid=(String)session.getValue("userid");
    if(uid==null){
        out.print("<script>parent.window.location='/login.jsp';</script>");
    }
      

  13.   

    LS好样的!只有你才明白LZ的意思
      

  14.   

    每个页面加一个IF语句判断session是否为空,是比较好的方法
      

  15.   

    parent.window.location
    没试过在多层框架下能不能到IE的最顶部窗口??