dcsimg
Java Servlet/Java Beans Design Issue: Thoughts needed
4 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   John_Smith
Posted On:   Tuesday, April 20, 2004 09:46 PM

Hello, I have a design issue involving java servlets/java beans/jsps (sort of MVC arch.) I have designed a webapp wherein a number of users can login and retrieve search customer records and update the records when required. Typically say when User1 searches the database for customers basing on a particular criteria, a hashtable will be generated by a servlet containing several customer beans and this hashtable will be saved in his session. At the same time when a user say User2 searches the database for customers basing on a different criteria again a Hashtable containing sever customer beans will be saved in User2's session. Now it is possible that a particular customer record (say customer1) is sto   More>>

Hello,

I have a design issue involving java servlets/java beans/jsps (sort of MVC arch.)

I have designed a webapp wherein a number of users can login and retrieve search customer records and update the records when required.

Typically say when User1 searches the database for customers basing on a particular criteria, a hashtable will be generated by a servlet containing several customer beans and this hashtable will be saved in his session.

At the same time when a user say User2 searches the database for customers basing on a different criteria again a Hashtable containing sever customer beans will be saved in User2's session.

Now it is possible that a particular customer record (say customer1) is stored in the sessions of both User1 and User2.

Now User1 updates customer1's details and stores the updated info in the database.
Now at this time customer1's details in User2's session (stored as a bean in the hashtable) are not updated ! So now when User2 tries to store the details into the database he will be overwriting the changes made by User1.

I want a solution as to how to solve this particular problem.....

I would really appreciate different thoughts and different solutions ....

Thanks

JN

   <<Less

Re: Java Servlet/Java Beans Design Issue: Thoughts needed

Posted By:   Murtuza_Bohri  
Posted On:   Wednesday, April 21, 2004 10:19 PM


This seems to be common problem in multiuser based Application.



In this Case you can use Object Lock Concept.



Initially when a User Asks for a Customer all of them will be available for Read only purpose. when a user wants to edit the Customer. at the client side user will click Edit button request will go to server requesting for a lock on the Customer if it is already locked by another customer It won't be available for Editing.
Client need to wait to acquire the lock.(Either server itself notifies the user with latest copy or user requests the edit after some time)

Re: Java Servlet/Java Beans Design Issue: Thoughts needed

Posted By:   Zac_Jacobson  
Posted On:   Wednesday, April 21, 2004 10:30 AM

EJBs can be used (perhaps heavy-handedly) to address this. Each user's session would hold a proxy to the actual bean that lives in the bean container, so changes made to it are accessible to all users.

You'd still have to consider how to deal with changing data; you can't really push updates to browsers, you can only show a change next time a user makes a request to your webapp.

Re: Java Servlet/Java Beans Design Issue: Thoughts needed

Posted By:   moon_departed  
Posted On:   Tuesday, April 20, 2004 11:52 PM

by implementing another extra column in your table design (eg. versionNumber)... then check on version number when perform update database. this should solve the problem too.

Re: Java Servlet/Java Beans Design Issue: Thoughts needed

Posted By:   Gajanan_Choudhari  
Posted On:   Tuesday, April 20, 2004 10:33 PM

I think by implementing SingleThreadedModel, problem can be solved.
Regard,
Gajanan
About | Sitemap | Contact