wood burning stoves 2.0*
The moose likes JSP and the fly likes JSP synchronization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP synchronization" Watch "JSP synchronization" New topic
Author

JSP synchronization

Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
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

Joined: Jun 18, 2004
Posts: 28
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

Joined: Jan 07, 2004
Posts: 270
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP synchronization
 
Similar Threads
Accessing session or application attributes from within a JavaBean
Someone Must Have an Example Like This!
Help with a gui requirement
2 types of clients access the same BD?
How to read XML in a Message Driven Bean?