views:

33

answers:

1

What is the best way to restrict concurrent user access in any web application?

Existing problem:

We have different reports in our web application. if one user is accessing any report we must not allow other users to access the same report. How can we achieve this?

Proposed solution:

  • create singleton class which will hold the report info object with report type and date so if user first time accesses report create this singleton object with current time
  • if user keeps open this report without doing any operation after 30 min the scheduler will close this report.
  • if other user is trying to access same report by checking the singleton object is containing the report info or not if not we are allowing.

Is this approach the best or is there any better approach? What are the best ways we can achieve this?

+1  A: 

I am not sure if by reports you mean some screen in your web application. In that case, you could create a table in a database to track user access to reports. A user can access a report only if it is available or own by him. A report gets freed when the user leaves the screen or his session ends, you can create a session listener and a context listener that cleans up ownership of reports.

svachon
+1 for the locking approach.
Pascal Thivent