aspose file tools*
The moose likes General Computing and the fly likes How does a server comes to know that a request is cancelled? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "How does a server comes to know that a request is cancelled?" Watch "How does a server comes to know that a request is cancelled?" New topic
Author

How does a server comes to know that a request is cancelled?

chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Hi all,

For instance I made a request to a server by clicking a link or typing the url manually, later I press escape key on my keyboard or I simply close the browser or I refresh the page which will spawn a new request. In all these cases the server is processing a request and the client has changed his options. How will the server come to know that the client has disconnected or cancelled the request.

What I think is whenever a client sends a request a http connection is made and the connection will be open until the request is served. In any case the client interrupts the request, either the request or the connection will be closed. Can anyone please comment on this.

Thank you all in advance. Good day.


Love all, trust a few, do wrong to none.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41839
    
  63
The most likely scenario is that the connection gets closed, which the server will notice (possibly by an exception being thrown) when trying to send a response. Before that, the processing of the request will continue as it normally would.


Ping & DNS - my free Android networking tools app
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Ulf Dittmer wrote:The most likely scenario is that the connection gets closed, which the server will notice (possibly by an exception being thrown) when trying to send a response. Before that
If the server throws an exception definitely it will be logged in the log files and I don't see one in my logs.
Ulf Dittmer wrote:the processing of the request will continue as it normally would.
If the processing of the request continues then definitely it is a serious issue. Why is the design like this. Any guess.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41839
    
  63
If the processing of the request continues then definitely it is a serious issue.

That really depends on the use case. There is no single right answer to this, there are good points for either approach. You just need to be aware of this, and design your web app accordingly (meaning, allow for the fact that a request may have been processed, even though its result was not shown to the user).
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Hi Dittmer, I wrote a sample servlet, introduced a break point, then requested the servlet and when the break point had hit I closed my browser and then tried to debug. I dint see any exceptions in the logs.

Why is the server log not showing the IO exceptions?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41839
    
  63
Note that I said "The most likely scenario". It's perfectly possible that something else happens - I've never tried to find out, especially as this is likely dependent on the server you're using. So whatever happens on the server you're using may not be what happens on some other server.

So your code writes (and flushes) an OutputStream that is connected to a connection that is no longer valid, and the servlet code finishes without an exception? That's interesting, and not what I would have expected. Of course, servlets operate on a higher level than sockets, and need not necessarily be aware what happens underneath.
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Ulf Dittmer wrote:Note that I said "The most likely scenario". It's perfectly possible that something else happens - I've never tried to find out, especially as this is likely dependent on the server you're using. So whatever happens on the server you're using may not be what happens on some other server.
Yeah, this is also right. I agree with you.
Ulf Dittmer wrote:So your code writes (and flushes) an OutputStream that is connected to a connection that is no longer valid, and the servlet code finishes without an exception? That's interesting, and not what I would have expected. Of course, servlets operate on a higher level than sockets, and need not necessarily be aware what happens underneath.
Yes, the servlet finishes without any exception. So you mean to say that after the servlet's execution finishes the control is transferred to some other lower level class which might throw an exception but is not being logged. Am I right?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41839
    
  63
There may be something that gets logged, but is not visible due to the logging level being set too high. You can find out what happens be stepping through the servlet container's code in your debugger.
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Ulf Dittmer wrote:There may be something that gets logged, but is not visible due to the logging level being set too high. You can find out what happens be stepping through the servlet container's code in your debugger.
Thank you. I will do that. Thanks for your patience and help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How does a server comes to know that a request is cancelled?