下面一段代码竟然引起反复打开的时候IE进程挂起

187 篇文章 0 订阅
68 篇文章 0 订阅
var lchs = "close";
window.onunload = function() {
 if (lchs == "fresh") {
  if (window.screenLeft > 10000) {
   logout();
  }
 } else {
  logout();
 }
}
window.onbeforeunload = function() {
 lchs = "fresh";
}

function logout() {
 Ext.Ajax.request({
  url : 'servlet/LogoutServlet',
  params : {
   type : 'Logout'
  },
  success : function(response, opts) {
   var val = Ext.util.JSON.decode(response.responseText);
  }
 });
}


LogoutServlet'

LogoutServlet:

package com.segsec.gisap.servlet;

import java.io.IOException;
import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.general.Constants;
import com.general.JsonUtil;
import com.segsec.gisap.MainSessionBean;

public class LogoutServlet extends HttpDispatchServlet {
	private static final long serialVersionUID = 1L;
	public void Logout(HttpServletRequest request,HttpServletResponse response, MainSessionBean session) throws IOException{
/*         	response.setHeader("Pragma","No-cache");  
        	response.setHeader("Cache-Control","no-cache");  
        	response.setDateHeader("Expires",  0); */
        	request.removeAttribute("MainSession");
    		request.getSession().invalidate();
    		HashMap hm = new HashMap();
    		hm.put(Constants.NO_SESSION_INFO_KEY, true);
    		JsonUtil.responseJsonObject(response, hm);
	}
}


HttpDispatchServletHttpDispatchServlet:

package com.segsec.gisap.servlet;


import java.io.IOException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import com.general.Constants;
import com.general.JsonUtil;
import com.segsec.gisap.MainSessionBean;



public class HttpDispatchServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	private static Logger logger = Logger.getLogger(HttpDispatchServlet.class);
	
	protected Class<?> clazz = this.getClass();
	
	protected Map<String, Method> methods = new HashMap<String, Method>();

	protected Class<?> types[] = {HttpServletRequest.class, HttpServletResponse.class, MainSessionBean.class};
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//System.out.println("class:" + clazz.getName() + "\ttype:" + request.getParameter("type"));
		Object obj = request.getSession().getAttribute("MainSession");
		String ICURURL = null;
		if(!MainSessionBean.class.isInstance(obj)){
			logger.debug("Error: The main session is null.");
			System.out.println("错误:你没有登录系统!");
			ICURURL = request.getServerName() + ":" + request.getServerPort() + request.getRequestURI();
			System.out.println("请求的Servlet是:"+ICURURL);
			Map<String, Object> map = new HashMap<String, Object>();
			map.put(Constants.NO_SESSION_INFO_KEY, true);
			JsonUtil.responseJsonObject(response, map);
			return;
		}
		MainSessionBean mainSession = (MainSessionBean) obj;

		String method= request.getParameter("type");
		if(method == null){
			logger.info("Error: The parameter(type) is null.");
			System.out.println("错误:没有得到要求的method,请检查是否传输了type参数!");
			ICURURL = request.getServerName() + ":" + request.getServerPort() + request.getRequestURI();
			System.out.println("请求的Servlet是:"+ICURURL);
			System.out.println("请求的method是:"+method);
			return;
		}	 
        Method m = null;
        try {
        	m = this.getMethod(method);
        	request.setCharacterEncoding("UTF-8");
    		//response.setCharacterEncoding("UTF-8");
        	response.setContentType("application/x-json;charset=UTF-8");
        	m.invoke(this, request, response, mainSession);
        }catch (NoSuchMethodException e) {
        	e.printStackTrace();
        	logger.info("Error : don`t find the " + method + " method.");
			ICURURL = request.getServerName() + ":" + request.getServerPort() + request.getRequestURI();
			System.out.println("请求的Servlet是:"+ICURURL);
        	System.out.println("错误:没有找到" + method + "方法!");
            return ;
        }catch (Exception e) {
        	e.printStackTrace();
        	logger.info("Error : This is error in the " + method + " method.");
			ICURURL = request.getServerName() + ":" + request.getServerPort() + request.getRequestURI();
			System.out.println("请求的Servlet是:"+ICURURL);
        	System.out.println("错误:调用" + method + "方法出现错误!");
            return;
        }    
	}
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
		this.doGet(request, response);
	}
	
	private Method getMethod(String name) throws NoSuchMethodException {
		synchronized (methods) {			
	        Method m = (Method)methods.get(name);
	         if (m == null) {
	             m = clazz.getMethod(name, types);
	             methods.put(name, m);
	         }
	         return (m);
		}
	}
}


 

说明:

上面的代码我是放在一个页面B.html中,LogoutServlet中处理也很简单,就是去清理一下Session。

 

我在A.html里面有个按钮,window.open('B.html'),在IE中如果反复点击打开B.html然后关闭,这样打开不了几次IE的进程就挂死,IE6、IE7、IE9都有这个问题,IE8没有测试,firefox没有问题。

 

IE7、IE8、IE9再某个进程卡死后,可以新开选项卡正常打开B.html但原选项卡就没有办法打开了。

 

不知引起问题的真正原因是什么?反正去掉这段代码就正常了。


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

冷月宫主

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值