• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

User name display problem

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a web application using Struts JSP, Servlets.
On top of each page, the user name logged in is displayed.
I have created a UserDTO class for this with static variables.
However, I face a problem here.
When more than one user is logged in concurrently and perform operations, the user name is displayed interchangeably and gets messed up.
Because whichever user logs in latest overwrites the UserDTO static variables.
How to get around this problem?
I want to find a way where the user name can be tracked for each user separately and displayed accordingly.
Please help me..
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your UserDTO object should not be using static variables. Use regular instance variables instead. One characteristic of a static variable is that it's the same for every instance of the class. Therefore, it's not surprising that the variable takes the value of the last user that signed on.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic