File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes What happens if multiple refresh requests are sent? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "What happens if multiple refresh requests are sent?" Watch "What happens if multiple refresh requests are sent?" New topic

What happens if multiple refresh requests are sent?

Alexey Gor

Joined: Jul 13, 2004
Posts: 27
I am confused -

what happens when user repeatedly presses the F5 button (really quickly)?

Does original request keep executing?

What happens to all these bazzilion requests being made?

What happens to the session scope?

thank you!
Zip Ped
Ranch Hand

Joined: Jul 26, 2005
Posts: 336
A refresh does not affect any request or Session scope variables. A refresh might not be idempotent(by HTTP standards POST is not Idempotent but your implementation might be) if you are using a POST method to send data back to the server.

The request variables do not go out of scope on a refresh as the data being requested from the server on each refresh is the same as the one that was sent in the first request.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
Does original request keep executing?

Each request will execute in its own Thread as provided by the servlet engine. There is no telling which will finish executing first since they all have the same priority.

Since each request uses the same ID, they all share the same session object. If this is a problem you can synchronize on the session object, thus forcing the other request Threads to wait for access.

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
One request will (probably) send a response back to the browser. The others will find that the browser is no longer interested in any response and get an exception something like connection reset by peer. My Wiki server handled this poorly for a while and banging on refresh was a good way to blow out the stack and write megabytes of log files.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1090
Refresh behaviour also depends on the browser being used. I feel Firefox handles this very nicely. It would queue up all the requests. In case of IE it fires two(or more) seperate requests at the same time.
I agree. Here's the link:
subject: What happens if multiple refresh requests are sent?
jQuery in Action, 3rd edition