0

I'd like to provide a webservice that can preserve state for a client. The response will have a subset of a list, while the full list should stay on the server side.

An initial client request will get an ID returned that can be used in further processes to obtain more resutls (similar to pagination).

How could I create such a stateful webservice? Is a static HashMap<ID, List<Items>> the way to go? Are static lists shared among threads (as every client request to the webservice will run in it's own thread)?

Could you recommend anything?

membersound
  • 81,582
  • 193
  • 585
  • 1,120
  • The `HashMap` is looking good, but you may need give some hand of a DB. and yes this list will be shared belong to all threads. for ensuring about the thread-safety, just lock the related `List` while working on it. –  Oct 31 '13 at 10:17
  • Shouldn't web services be stateless? – Atul Oct 31 '13 at 10:20

1 Answers1

2

To use HashMap as webservice hash map as webservice

For static variables shared among threads thread sharing

Community
  • 1
  • 1
Ashish
  • 735
  • 1
  • 6
  • 15