Frage

I need to maintain a list of objects in a web application. This list can be viewed or modified (items added or deleted) by any user of the web application. There are chances that many users are accessing (modifying) the list almost at the same time. Which is the right approach to share the list. I can think of 2 ways.

  1. Static variable
  2. ServletContext

Please let me know which one is right and why. Also, please let me know if there is any other better way.

EDIT Issue is sharing objects between different users of application.

War es hilfreich?

Lösung 2

You can use database, custom datasource (simple list wrapped by DataSource interface) and many more, but...

any instance of the web application

should it be any user of webapp, right?

Andere Tipps

Database if speed is not the most important factor. If you need speed some shared memory solution with locking is good. Such as Hazelcast http://www.hazelcast.com/

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top