seseion 超时

<!--
 闲置超时提示, 并跳出系统.
 
 Created by HuQingmiao on 2008-03-22
-->

<%@ page language="java" contentType="text/html;charset=GBK" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>


<html>

<head>

<script language="JavaScript" type="text/JavaScript">
 <!--
 function gotoLogon(){
 
   if(window.opener!=null){
  
     if(window.parent!=null){
        window.opener.parent.top.location="<%=request.getContextPath()%>/index.jsp";
        window.close();
     }else{
        window.opener.top.location="<%=request.getContextPath()%>/index.jsp";
        window.close();
     }
 
   }else{
      window.top.location="<%=request.getContextPath()%>/index.jsp";
   }
 }
 //-->
</script>

</head>

<body onload="gotoLogon()">
</body>


</html>

 

  <filter>
    <filter-name>SessionFilter</filter-name>
    <filter-class>cn.net.gmt.jmpt.common.SessionFilter</filter-class>
  </filter>  
  
<filter-mapping>
 <filter-name>SessionFilter</filter-name>
 <url-pattern>*.do</url-pattern>
  </filter-mapping>
 
  <filter-mapping>
 <filter-name>SessionFilter</filter-name>
 <url-pattern>*.jsp</url-pattern>
  </filter-mapping>
   <session-config>
    <session-timeout>60</session-timeout>
  </session-config>

 

 

public class SessionFilter implements Filter {

    protected Logger log = LogFactory.getLogger(this.getClass());

    private FilterConfig filterConfig = null;

    public void init(FilterConfig filterConfig) throws ServletException {
        this.filterConfig = filterConfig;
    }

    public FilterConfig getFilterConfig() {
        return filterConfig;
    }

    public void setFilterConfig(FilterConfig filterConfig) {
        this.filterConfig = filterConfig;
    }

    public void doFilter(ServletRequest request, ServletResponse response,
            FilterChain chain) throws IOException, ServletException {

        HttpServletRequest httpRequest = (HttpServletRequest) request;
        HttpServletResponse httpResponse = (HttpServletResponse) response;

        //请求路径 URL
        String path = httpRequest.getServletPath();

        if (!path.endsWith("/portal.do") && !path.endsWith("time.jsp")
    && !path.endsWith("index.jsp") && !path.endsWith("error.jsp")
    && !path.endsWith("fetchNumber.do")
    && !path.endsWith("quecallQuery.do")) {

            Object user = httpRequest.getSession().getAttribute(
                    SessionConstant.OPERATOR);

            if (user == null) {

                //转发带参数的请求
                //                ServletContext context = filterConfig.getServletContext();
                //                RequestDispatcher dispatcher = context
                //                        .getRequestDispatcher("/index.jsp");
                //                dispatcher.forward(httpRequest, httpResponse);

                String contextPath = httpRequest.getContextPath();
                httpResponse.sendRedirect(contextPath + "/common/time.jsp");
                return;
            }
        }
        chain.doFilter(request, response);
    }

    public void destroy() {
    }

}

 

你可能感兴趣的:(JavaScript,bean,jsp,Web,struts)