java.io.IOException: write() ...writer is closed

[ 2007-08-10 15:03:23 | Author: zhenhua ]
Font Size: Large | Medium | Small
java.io.IOException: write() forbidden after writer is closed

在resin3.1以前的版本中,out.close()后可以继续“输出内容”,但后续的内容已经因为out.close()而不起作用了,不会显示在浏览器中,可是在resin3.1中,out.close()的规则似乎有变,比如下面这个网页运行时就会报错
<%@ page language="java" contentType="text/html;charset=GBK"%>
<%
int i=0;
if(i<1){
out.close();
}
%>
test

报错内容::java.io.IOException: write() forbidden after writer is closed
而在3.0.8中这个网页可以正常浏览

作如下改动后,3.1下也正常了。

方法一、
<%@ page language="java" contentType="text/html;charset=GBK"%>
<%
int i=0;
if(i<1){
out.close();//测试发现,这句加与不加都是一样的效果,还不清楚到底需不需要
return;
}
%>
test

方法二、
<%@ page language="java" contentType="text/html;charset=GBK"%>
<%
int i=0;
if(i<1){
out.close();
}
else
{
%>
test
<%}%>
Comments Feed Comments Feed: http://www.zhenhua.org/feed.asp?q=comment&id=474
UTF-8 Encoding Trackback URL: http://www.zhenhua.org/trackback.asp?id=474

There is no comment on this article.

If you feel this site you find this information helpful, please click on the donation, which is voluntary,Thank you.
Post Comment
Smilies
[arrow] [biggrin] [confused] [cool]
[cry] [eek] [evil] [exclaim]
[frown] [idea] [lol] [mad]
[mrgreen] [neutral] [question] [razz]
[redface] [rolleyes] [sad] [smile]
[surprised] [twisted] [wink]
Enable UBB Codes
Auto Convert URL
Show Smilies
Hidden Comment
Username:   Password:   Register Now?
Security Code * Please Enter the Security Code