This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Servlets and the fly likes Scenarios in which session attributes are not thread safe? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Scenarios in which session attributes are not thread safe?" Watch "Scenarios in which session attributes are not thread safe?" New topic
Author

Scenarios in which session attributes are not thread safe?

Rao Potla
Greenhorn

Joined: Jan 14, 2012
Posts: 11
please give some suggestions for me how to send multiple requests at the same time to access session attributes in non thread safe manner,

Thanks in advance.
RaoPotla
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19719
    
  10

Click the button which sends a request to a servlet which uses session attributes. Then before that servlet sends its response, click the button again. Now you have two threads running the same servlet and using the same session.

To do this your servlet is going to have to run rather slowly, so that you have time to click the button twice.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63196
    
  69

Also multiple Ajax requests, frames, iframe, and tabs in the same browser.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12999
    
    5
Just look at how many requests go to make up a modern HTML page - each image, css, js, etc resource is loaded by a separate request, managed "simultaneously" by your browser, and thus "simultaneous" on the server side and each seeing the same session.

Bill
Rao Potla
Greenhorn

Joined: Jan 14, 2012
Posts: 11
Paul Clapham wrote:Click the button which sends a request to a servlet which uses session attributes. Then before that servlet sends its response, click the button again. Now you have two threads running the same servlet and using the same session.

To do this your servlet is going to have to run rather slowly, so that you have time to click the button twice.


thank you , its very helpful
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Scenarios in which session attributes are not thread safe?
 
jQuery in Action, 3rd edition