Thread safety in JSF


Assume that we have Spring bean UserController with singleton scope.

All my further reasoning is based on my assumption that "singleton" scope is almost similar to application scope i.e. we have only one instance for all users. If this is wrong assumption then tell me about it, please.

So, we have a web-form with several fields. Two users fill this form simultaneously. And they both press Submit button at the same time. Our UserController is a backing bean for that form.

My question: is it possible that part of the fields in UserController will contain values from first user, and the rest of the fields will contain values from the second user?

  1. You are right that singleton = application. Spring's WebApplicationContext is stored in the ServletContext, so it's one per application.

  2. Your controllers shoud not be of singleton scope. They should be either request or session scoped. Your service layer should consist of singletons

  3. If your controller is singleton it is pretty certain that the whole thing will be messed up ;)