This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Multiple user Ajax problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Multiple user Ajax problem" Watch "Multiple user Ajax problem" New topic
Author

Multiple user Ajax problem

anuja Kar
Greenhorn

Joined: Jun 15, 2010
Posts: 9
Hello,

In my web application. One page is dynamically loaded with ajax call. When Single user is logged into the system the page is rendered properly. but multiple user sessions behave abnormally. Sometimes value rendered by ajax is from other user session. Can any one tell me what could be causing this problem . Any help will be appreciated.
Thanks in advance
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Sounds like what you get when your code has instance variables holding user specific information.

Remember one instance of your jsp/servlet code may handle many many requests "at the same time." User specific information must be stored where only one request can see it.

Bill
anuja Kar
Greenhorn

Joined: Jun 15, 2010
Posts: 9
Hello,
Thank you for the response. But my problem is not regarding user specific information . I have three combo box to choose from
each combo sends an ajax request and fill the next combo . On the last combo change im displaying a table . When i am testing it from the development machine it is working fine. But a when around 20 users use the page at same time. The response for the first person sometimes displayed i the third persons browser(which is wrong according to the values he selected) and first person is not getting any response from server. I am not sure why this happens . is it because the page fires more ajax request than the browser allow ? or server is swamped with ajax requests . Can any one guide me regarding this ?

Thanks & Regards
Anuja

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
What Bill is getting at is that the server-side code needs to be written in a thread-safe manner, so that simultaneous accesses don't clobber each other's data. Specifically, shared mutable state needs to be protected - instance variables in a servlet are one such case, as are context attributes.


Ping & DNS - my free Android networking tools app
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
But my problem is not regarding user specific information .


But what is the following if not user specific information??

The response for the first person sometimes displayed i the third persons browser(which is wrong according to the values he selected)


Bill
anuja Kar
Greenhorn

Joined: Jun 15, 2010
Posts: 9
Hello ,
Thanks bill & ulf for clarification. I was confused about the user specific bit. Can you please suggest how ajax call can be made thread safe.

Regards,
Anuja
 
Don't get me started about those stupid light bulbs.
 
subject: Multiple user Ajax problem
 
Similar Threads
"JSF" + "RIA" == lie
Update a region with new content from Ajax response
window.setInterval messing up jQuery button handler
AJAX and Servlet question
creating a text file from JSP