tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fang Yidong <>
Subject Re: How can I get notified when the HTTP client close the connection?
Date Thu, 22 May 2003 07:13:29 GMT
The problem is: I can't catch any Exception at all.
Tim wote:
You might be able to catch an IOException. But you probably really won't know
the exact amount of information you sent since there is some buffering being
奕东 方 wrote:
> I notice that the following jsp is still running when the client terminates his web browser:

> <% 
> for(int i=0;i<100;i++){ 
>        try{ 
>                Thread.currentThread().sleep(2000); 
>                System.out.println((i+1)+": Hello"); 
>                for(int j=0;j<1000;j++) 
>                out.println("hello"); 
>        } 
>        catch(Exception e){ 
>                System.out.println("Exception"); 
>                e.printStackTrace(); 
>        } 
> } 
> %> 
> So althougth the jsp/servlet can no more write any data to the browser(which is terminated
by the client),the jsp/servlet can still write the the jsp output stream "out" without any
exception thrown by the "println" method,and the jsp/servlet is blind to the fact that it
can no more really write any thing to the client(the client can no more receive the data),it
keeps running util it finishes the "for" cycles,just as nothing happens. 
> But I want to be notified when the HTTP connection is close by the web client.How can
I do that? 

Do You Yahoo!?
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message