jQuery in Action, 2nd edition*
The moose likes JSF and the fly likes multiple concurrent ajax calls to multiple servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "multiple concurrent ajax calls to multiple servlets" Watch "multiple concurrent ajax calls to multiple servlets" New topic
Author

multiple concurrent ajax calls to multiple servlets

Funkaj Kohli
Greenhorn

Joined: Feb 24, 2011
Posts: 12

Hey,

I am using AJAX at client side to make calls(POST calls) to multiple servlets of the same app. The spec requires an AJAX call to wait for some event to happen(at the server side) before this call completes. Meanwhile other AJAX calls are being made to some OTHER servlet(s) all of which get completed immediately.

The latter calls returns some data on completion without a hitch. However, when the former(the one which was waiting for an event) completes, it "tries" to return some data too, but it returns the output of the latter calls and that too more than once.

I am using POST for all these calls and suspect that "constant-handshaking" is behind all this. I have also tried flushing the stream but that didn't help either.

I am using Tomcat, chrome/mozilla and notepad.

If the problem is still not clear, I can post the code too.

Eagerly waiting,
Pankaj Kohli


Pankaj Kohli
OCJP 6
Its the question that drives us.
H Jetly
Ranch Hand

Joined: Aug 26, 2010
Posts: 41

Is this JSF issue ?
If so ajax requests can be pointed to different managed beans.


Harsh Jetly
Funkaj Kohli
Greenhorn

Joined: Feb 24, 2011
Posts: 12

No it was a logical error. I was using the same XMLHttpRequest() object to make multiple calls. So while the former AJAX waited for a response(on event onreadystatechange), the latter call made a new object and used it. Hence, I'd get the last completed response(ResponseText) on any former calls.

Got it yesterday.

I'm sorry for not removing the post.

Thank you for your time.
 
Consider Paul's rocket mass heater.
 
subject: multiple concurrent ajax calls to multiple servlets