File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Sending multiple request on a Single Click Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Sending multiple request on a Single Click" Watch "Sending multiple request on a Single Click" New topic
Author

Sending multiple request on a Single Click

Ravi Kotha
Ranch Hand

Joined: Mar 02, 2006
Posts: 53
Frnds,

I have a question on sending multiple requests. Let's say I send multiple requests to the same servlet (Ofcourse two in my case) on a single click of button, is there a guarantee that those requests would be processed in the same order?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

No.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2718
    
    6

But is it really possible to send multiple requests on a single button click?
Haven't tried it yet but I think the first request is processed and the
servlet will generate some response and the second request does not get a chance.

And Ravi please UseRealWords "Frnds" is not a real word.


SCJP, SCWCD.
|Asking Good Questions|
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

Originally posted by Amit Ghorpade:
But is it really possible to send multiple requests on a single button click?
Sure it is. A click handler can be defined to fire off any number of requests to newly-opened windows, to iframes, as Ajax requests and so on.

In any case, the order of delivery to the server is completely nondeterministic.
Rodrigo Tomita
Ranch Hand

Joined: Apr 28, 2008
Posts: 70
And both requests will be processed in parallel, may I add.
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2718
    
    6

Thanks for the explanation Bear,
Sure it is. A click handler can be defined to fire off any number of requests to newly-opened windows, to iframes, as Ajax requests and so on.

I am not familiar with a click handler
But can a click handler send multiple requests to a servlet?
If yes then I think after the first request, a response will be generated and as I said above the second request wont get a chance.
Is it like that some client side buffering is done for requests?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

Originally posted by Amit Ghorpade:
[QBI am not familiar with a click handler[/QB]
A JavaScript function can be set up to handle clicks on any DOM element.

But can a click handler send multiple requests to a servlet?
Yes, as I explained. The client has no idea whether the request is being sent to a servlet or not. They're all just requests to the server.

If yes then I think after the first request, a response will be generated and as I said above the second request wont get a chance.
You are assuming that the browser will block waiting for the response. Not always. Not with Ajax and not with iframes.

Is it like that some client side buffering is done for requests?
There is some of that. Browsers will limit the number of simultaneous requests. How that's handled is browser-specific.
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2718
    
    6

Thanks for that great explanation Bear

Things are pretty clear for me now
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sending multiple request on a Single Click