Session超时后跳转到登录页

 

boolean sessionTimeOut = false;
		if (exception != null) {
			if (exception.getCause() instanceof com.chinacreator.security.SessionTimeoutExcetpion){
				//response.sendRedirect(request.getContextPath());
				//return;
				sessionTimeOut = true;
			}
}

 

<div Style="width: 100%; display: none" id="exceptionDiv">
	<img src="../include/themes/default/images/messager_error.gif" />	
<a onClick="javascript:showT();" href="#">查看详细异常</a>
	<div id='exceptions'
		style="display: none; OVERFLOW: auto; width: 100%; height: 460">
		
		<pre>
			<%
				exception.printStackTrace(new java.io.PrintWriter(out));			 	
			%>
		</pre>		
	</div>
	
</div>
 

 

 

<script type="text/javascript">
<!--
	var isTopOtherSystem = false;//最上层窗口是不是本系统
	//返回层级窗口
		function findOpenerWin(win){
				var openerWin = win.top.dialogArguments;				
				if (!openerWin){
						openerWin = win.top.opener;					
				}
				if (openerWin){
					try
					{
							openerWin.top.document.location;
					}
					catch(e)
					{					
							isTopOtherSystem = true;										  		
					}			
					if (isTopOtherSystem){
						return openerWin;
					}
					return findOpenerWin(openerWin)
				}
				else{
					try
					{
							win.top.document.location;
					}
					catch(e)
					{					
							isTopOtherSystem = true;										  		
					}			
				}
				return win;
		}	
		
		if (<%=sessionTimeOut%>){
			var openerWin = findOpenerWin(this);
			
			alert("会话超时,请重新登录!");
			//如果本窗口就是原始窗口
			if (openerWin == this){
				this.top.location.href = "<%=request.getContextPath()%>";
			}
			else{
				//关闭当前窗口
				this.close();
				//如果没有跨域	,即原始窗口不是其他系统			
				if (!isTopOtherSystem){
					openerWin.top.location.href = "<%=request.getContextPath()%>";
				}				
			}			
		}
		else{
			document.getElementById("exceptionDiv").style.display = "block";
		}
//-->
</script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值