This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Struts and the fly likes User name display problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "User name display problem" Watch "User name display problem" New topic
Author

User name display problem

Steve Renard
Ranch Hand

Joined: Apr 27, 2007
Posts: 66
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..
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
 
GeeCON Prague 2014
 
subject: User name display problem