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 οnlοad="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() {
    }

}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值