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 Servlets and the fly likes Sessions and requests 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 » Servlets
Bookmark "Sessions and requests" Watch "Sessions and requests" New topic
Author

Sessions and requests

Clive Walden
Greenhorn

Joined: Aug 24, 2010
Posts: 2
Hi All,
I hope this is the correct forum for these questions.

1. Do HTTPRequest and xmlHTTPRequests from a users browser page share the same session?

2. If so, can race conditions occur whereby an xmlHTTPRequest can start processing before an HTTPResponse
has returned? i.e. Could one browser tab send an xmlHTTPRequest shopping cart change of item while another tab is processing a HTTPRequest calculating total cost such that we have no way of knowing which items are actually in the calculation.

I hope I am making sense.

Another way of asking:

If I have an object stored in a session with a global variable (pointer) to a request, could a second request to the session overwrite that variable before the first request had finished processing so that the process started requesting parameters that it thought were from the first request but, in fact, were from the second request?

I hope this makes sense. We have database accesses and calculations that can take time (the above was only an example not real world) and with AJAX and tabbed browsers I can see xmlHTTPRequests and HTTPRequests in a single session arriving faster than they are handled.

I do not think I need help in managing that situation. I just need to know if I need to bother.

Thanks,
Clive
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

Clive,
Welcome to JavaRanch!

Yes. The user has one HttpSession regardless of whether you are making a regular request or using AJAX. And yes, race conditions can occur.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Clive Walden
Greenhorn

Joined: Aug 24, 2010
Posts: 2
Jeanne Boyarsky wrote:Clive,
Welcome to JavaRanch!

Yes. The user has one HttpSession regardless of whether you are making a regular request or using AJAX. And yes, race conditions can occur.

Thanks. It is what I expected but could find nothing sufficiently definitive for my comfort.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sessions and requests
 
Similar Threads
Question on Filter
Storing Object Temporarily
Is session object thread safe.
HashMap problem
AJAX Controller