Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Session swapping problem under load

 
Ranch Hand
Posts: 89
  • 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
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
  • 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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • 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
  • 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.
 
Happily living in the valley of the dried frogs with a few tiny ads.
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic