aspose file tools*
The moose likes JSP and the fly likes Will the jsp execute if a user closes the browser? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Will the jsp execute if a user closes the browser?" Watch "Will the jsp execute if a user closes the browser?" New topic
Author

Will the jsp execute if a user closes the browser?

Neeraj Sharma
Greenhorn

Joined: Apr 24, 2003
Posts: 5
Hello All!
I have a jsp application that integrates with a database. I just want to know what happens if a user clicks a link and closes the browser while the request is through. Here there are 2 to 3 scenarios. What happens when a user closes the browser/click stop button immediately after clicking the link. In IE we see a status bar at the bottom. What happens when a user closes the browser/cliks stop button while it is halfway through?
I believe once the request reaches the web server, the transaction is complete.
I would greatly appreciate if you can give me some information regarding this.
Thanks!!
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

HTTP is stateless -- once a request has been made -- the server will fulfill it.
If after the user makes the request -- they close the browser (or click the stop button) -- the server will have no idea the user tried to "cancel" the request -- it will fulfill the request and attempt to return the response, but the resonse will not go through.
If the user hits reload -- another request will be made, same if they click a different link before the request could be fulfilled.


- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
Neeraj Sharma
Greenhorn

Joined: Apr 24, 2003
Posts: 5
Jessica:
Thanks for the reply. But I have observed a scenario. Let's take example of yahoo mail "Bulk Mail" and "Sent Mail". I tried clicking on them both one after another immediately. The result is random.
Also, what happens when the user hits stop button or close the browser when the request is still through(When the blue status bar below is half way through).
Thanks in anticipation.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
If the browser closes the socket, the servlet will get an IOException when it tries to write content - this will be when the buffer is full, or when out.flush() is called. So a JSP may not execute all the way through and the transaction will NOT be complete.
Its not uncommon to see this exception in logs.
Bill
Neeraj Sharma
Greenhorn

Joined: Apr 24, 2003
Posts: 5
Hello
I just checked it practically. Now after I made the request, while the status bar is still through
i.e immediately after i see the blue color in the status bar I closed the browser/ hit stop button. I noticed that the request was through and the database is updated. So once, the link is clicked it is through.
But, I am observing the following in the log file :
The first log is when I make the request and close the browser immediately (I can see the status bar below). The second log is when I wait till the end. They both look same
2003-04-25 11:29:57 SessionListener: sessionCreated('064BAAAD2AA39F7565B2961C2FBD0AD6')
2003-04-25 11:29:57 SessionListener: attributeAdded('064BAAAD2AA39F7565B2961C2FBD0AD6', 'wb3', 'pavan.WorkBean@1b717928')
2003-04-25 11:35:10 SessionListener: sessionCreated('53505D958B717354D82358D8EC1BA8F2')
2003-04-25 11:35:10 SessionListener: attributeAdded('53505D958B717354D82358D8EC1BA8F2', 'wb3', 'pavan.WorkBean@49a03929')
Neeraj Sharma
Greenhorn

Joined: Apr 24, 2003
Posts: 5
Hello
I just checked it practically. Now after I made the request, while the status bar is still through
i.e immediately after i see the blue color in the status bar I closed the browser/ hit stop button. I noticed that the request was through and the database is updated. So once, the link is clicked it is through.
But, I am observing the following in the log file :
The first log is when I make the request and close the browser immediately (I can see the status bar below). The second log is when I wait till the end. They both look same
2003-04-25 11:29:57 SessionListener: sessionCreated('064BAAAD2AA39F7565B2961C2FBD0AD6')
2003-04-25 11:29:57 SessionListener: attributeAdded('064BAAAD2AA39F7565B2961C2FBD0AD6', 'wb3', 'pavan.WorkBean@1b717928')
2003-04-25 11:35:10 SessionListener: sessionCreated('53505D958B717354D82358D8EC1BA8F2')
2003-04-25 11:35:10 SessionListener: attributeAdded('53505D958B717354D82358D8EC1BA8F2', 'wb3', 'pavan.WorkBean@49a03929')
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Will the jsp execute if a user closes the browser?