This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session swapping problem under load

 
kapil Gupta
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am developing a web application based on spring web MVC framework that runs in in tomcat server. The entry to the webapp is through a login page and after successful validation user is taken to home page that displays a greeting message like Good Morning Mr XYZ. The user name is set as session attribute from Login Servlet and is retrieved by the home page JSP.
During load testing it was noticed that the user name displayed in greeting message was of some other user. This problem occurred only twice and is not reproducible.
What could be the cause of this issue? Should I put the login code in synchronize block so there are no threading issues?
Thanks,
Kapil
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that you have no instance variables in your servelts or JSPs? Properly coded servlets/JSPs rarely need synchronization.
 
kapil Gupta
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, there are not instance variables in servlets other than the singleton spring beans (service classes) that further validates the user from database.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kapil Gupta:
Yes, there are not instance variables in servlets other than the singleton spring beans (service classes) that further validates the user from database.



That sounds like it could be a problem.
If you have a singleton object (shared by all requests) with instance variables, then it's to be expected that multiple requests could be sharing the same variables.

Can you post the code to one of these classes?
 
kapil Gupta
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following is the pseudo code for login

The user name is set as member variable of MyCustomSessionObject class and retrieved in the JSP from session object.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic