• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP synchronization

 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a JSP file I have a customerID which is stored in a session. This customerID I use to recieve (select only) some customer information from a database, through a java class. I have doubt about if there can be any synchronization problems, if more users is accessing the page the same time, and i.e. CUSTOMER A is recieving CUSTOMER B�s information and visa versa?

//In the jsp page, this method call the java class to select data from database
user.dataObject.User obj_user = obj_order.getCustomerInformation( customerID );

//Here I get the customer Name in the jsp page
String customerName = obj_user.getCustomerName();

Is it necessary to synchronize the method, which do the select query in the Java class to avoid that CUSTOMER A is recieving CUSTOMER B�s information?
[ November 30, 2005: Message edited by: Jeppe Fjord ]
 
C Broussard
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
couple things to keep in mind.. in your javabean obj_order.getCustomerInformation() make sure you're doing a "new" object creation so that each jsp call gets a new memory location. if you merely reuse a class variable or a static instance of that then you will have data corruption. assuming that's not the problem, as long as the variable is in session scope you theorectically shouldn't have to worry about customer b accessing customer a stuff.

it's kinda hard to tell from your code that you've posted.

www.binaryfrost.com
 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my code from the java bean:


Here I get the customerID from a session in an included JSP page:

java.util.Hashtable id = ( java.util.Hashtable ) session.getAttribute("ids");
int customerID = Integer.parseInt( ( String ) id.get("custID") );

- And in the JSP which include the first page I just call this bean with:

user.OrderData obj_order = obj_order = new user.OrderData( conn );
user.dataObject.User obj_user = obj_order.getCustomerInformation( customerID );

Do you see any synchronization problems in the way I get the customer information? One of the users has reported that he recieved another customer name, than his name?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic