tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fang Yidong <fangyid...@yahoo.com.cn>
Subject Re: How can I get notified when the HTTP client close the connection?
Date Sun, 25 May 2003 09:22:09 GMT
Tim,I think I've figure out why I can't catch an IOException on the client abort.It's the java.io.PrintStream!
I use PrintStream to get some convenience to write multi-part data boundary,but I fail to
read the PrintStream API documentation carefully:
 
A PrintStream adds functionality to another output stream, namely the ability to print representations
of various data values conveniently. Two other features are provided as well. Unlike other
output streams, a PrintStream never throws an IOException; instead, exceptional situations
merely set an internal flag that can be tested via the checkError method. Optionally, ...
 
 
So the following code never get an IOException even if the underlying stream fail to output
any data:
 
OutputStream out=new PrintStream(response.getOutputStream());
try{
  out.write(<data>);
}
catch(IOException e){
  /*never reached*/
}
 
Which is similar to my codes!
 
Thanks for all the days!
 
 





---------------------------------
Do You Yahoo!?
"相见不如聊天!不出门一样面对面!网络摄像头对对派送中~赶快用你的雅虎电邮帐号参与吧……
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message