This week's book giveaway is in the Java in General forum.
We're giving away four copies of Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework and have Michael Redlich on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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

 
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic