You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Trott, David" <dt...@glovia.com> on 2003/12/12 05:15:29 UTC

Detecting HTTP connection state in Tomcat 4.x

Hi

I have a batch transaction that takes a significant amount of time (more
than an hour).
However I have a requirement that the user needs to be able to kick of the
transaction from a web interface and be notified when it completes.

I know this isn't the best way to solve the problem, but I was wondering if
it would be possible to detect the HTTP connection state from tomcat 4.x.
I.e.: I kick off the batch transaction from a Servlet and wait for either:

- The transaction to complete at which point I notify the user.
- The http connection is closed (The browser gets closed), at which point I
cancel the batch transaction.

NOTE: The reason I am canceling the transaction is because it is expensive
to calculate.

I suspect that it not possible to detect the connection state because Tomcat
4.x only requires JDK 1.2, hence it cannot be using NIO.
As a result there are no methods to "reliably" detect whether the connection
is still open without reading or writing the connection.

However if someone could confirm my assumption (that it is not possible to
detect the state) it would be much appreciated.

Thanks,
David


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Detecting HTTP connection state in Tomcat 4.x

Posted by Tim Funk <fu...@joedog.org>.
DO NOT rely on connection state. This might actually cause a DOS attack on 
you. Use some ID to identify the transaction - then use a cookie (or session) 
with a META refresh to a page which can use that ID to see how the 
transacation is progressing. Upon finishing, the status page can send you to 
the confirmation (or whatever) page.

-Tim

Trott, David wrote:

> Hi
> 
> I have a batch transaction that takes a significant amount of time (more
> than an hour).
> However I have a requirement that the user needs to be able to kick of the
> transaction from a web interface and be notified when it completes.
> 
> I know this isn't the best way to solve the problem, but I was wondering if
> it would be possible to detect the HTTP connection state from tomcat 4.x.
> I.e.: I kick off the batch transaction from a Servlet and wait for either:
> 
> - The transaction to complete at which point I notify the user.
> - The http connection is closed (The browser gets closed), at which point I
> cancel the batch transaction.
> 
> NOTE: The reason I am canceling the transaction is because it is expensive
> to calculate.
> 
> I suspect that it not possible to detect the connection state because Tomcat
> 4.x only requires JDK 1.2, hence it cannot be using NIO.
> As a result there are no methods to "reliably" detect whether the connection
> is still open without reading or writing the connection.
> 
> However if someone could confirm my assumption (that it is not possible to
> detect the state) it would be much appreciated.
> 
> Thanks,
> David
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org