谢谢各位的解答,死循环应该是没有,我隐隐约约感觉到问题出在哪,但又说不上来,我的应用用的是JSF开发的,但我在开发过程中,有些地方没有用JSF的导航机制,代码如下,我想问的是,是不是开了太多的Request但又没关闭而引起的,再帮我分析分析,谢谢!/** &nb...
显示全部谢谢各位的解答,死循环应该是没有,我隐隐约约感觉到问题出在哪,但又说不上来,我的应用用的是JSF开发的,但我在开发过程中,有些地方没有用JSF的导航机制,代码如下,我想问的是,是不是开了太多的Request但又没关闭而引起的,再帮我分析分析,谢谢!
/**
* 返回到指定页面
* @param context
* @param message
* @param url
* @return
* @throws IOException
*/
public static boolean getMessage(FacesContext context,String message,String url ) throws IOException{
String contentType = "application/octet-stream;charset=gb2312";
HttpServletResponse response = (HttpServletResponse) context
.getExternalContext().getResponse();
HttpServletRequest request = (HttpServletRequest) context
.getExternalContext().getRequest();
response.setContentType(contentType);
PrintWriter out = response.getWriter();
out.print("");
//response.encodeRedirectURL(url);
out.flush();
context.responseComplete();
out.close();
return true;
}
/**
* 返回到指定页面
* @param context
* @param url
* @return
* @throws IOException
*/
public static boolean redirect(FacesContext context,String url ) throws IOException{
String contentType = "application/octet-stream;charset=gb2312";
HttpServletResponse response = (HttpServletResponse) context
.getExternalContext().getResponse();
response.setContentType(contentType);
PrintWriter out = response.getWriter();
out.print("");
out.flush();
context.responseComplete();
out.close();
return true;
}
/**
* 只提示信息,继续执行
* @param context
* @param message
* @param goon
* @return
* @throws IOException
*/
public static boolean getMessage(FacesContext context,String message,boolean goon) throws IOException{
String contentType = "application/octet-stream;charset=gb2312";
HttpServletResponse response = (HttpServletResponse) context
.getExternalContext().getResponse();
response.setContentType(contentType);
PrintWriter out = response.getWriter();
out.print("");
//out.flush();
context.responseComplete();
out.close();
return true;
}
/**
* 异步确认提示
* @param context
* @param code
* @param declare
* @throws IOException
*/
public static void confirm(FacesContext context,String code,String declare) throws IOException {
String contentType = "application/octet-stream;charset=gb2312";
HttpServletResponse response = (HttpServletResponse) context
.getExternalContext().getResponse();
response.setContentType(contentType);
PrintWriter out = response.getWriter();
StringBuffer buf = new StringBuffer();
buf.append("\n");
out.print(buf);
out.flush();
context.responseComplete();
}
public static String getResult(FacesContext context,String declare) throws IOException, InterruptedException {
Map map = context.getExternalContext().getSessionMap();
map.put("b",null);
confirm(FacesContext.getCurrentInstance(),"b",declare);
int l = 0;
while (map.get("b") == null) {
if (l > 15000) {
map.put("b", "false");
break;
}
l = l + 2000;
Thread.sleep(2000L);
}
return (String)map.get("b");
}
收起