Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

synchronize in struts

 
emmel torres
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I have a web application and will have users connected to it simmultaneous.

The problem is the next:

With Accept button go to Configuration Action class, and it makes a session.setattribute("configuration", config_object) for save some object into session, after it redirect to Generation Action class.

Generation Action class make a session.getattribute("configuration") for get the object saved in Configuration Action class, after it
Generation Action class make a session.setattribute("generation", generation_object), and session.setattribute("configuration", config_object_modified) after it redirect to the jsp.

In the jsp obtain the attributes with:
<jsp:useBean id="generation" scope="session" class="package.generationActionForm"></jsp:useBean>
<jsp:useBean id="configuration" scope="session" class="package.configurationActionForm"></jsp:useBean>

The problem is when two user acceded to click button I guess that the setattribute are saving like to application scope (getServlet().setattribute..) because both users the application display the same information and at the began the configuration was different. If the users acceded in different second the application run correctly.

If I synchronize the execute methods of Generation Action class and Configuration Action class the application runs correctly; but I dont want it, because if the user1 acceded to the database and his/her SQL Query runs slowly, the second user will be waiting until user1 finish.

Thanks! I hope I can help
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each user has a separate session.

If you're testing locally and attempting to simulate two users on a single machine then you might have a problem--different browsers handle the opening of new windows differently; some create a new session with the server, some don't. The best solution is to use two different browsers for two different users.

If two users on separate *machines* are getting the same session then something is very wrong with your server.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic