0

I'm rather new to Spring and I was just wondering if someone would be able to clear something up for me. What I am wondering is what is the scope of a spring mvc web application. Do users get a new instance of the application whenever they use it or is it like a singleton where everyone gets the same instance of the application?

For example, if I am storing some data in a controller that user 1 had accessed, and user 2 comes along and starts using the web application will user 2 see user 1's data or are they entirely separate instances?

I have tried to find an answer to this but with no luck. I have read about the different bean states within an application but haven't found anything about the application itself.

Any insight is greatly appreciated, HarleyQ14

1
  • It is my understanding that in your description, User 2 will NOT be able to see user 1's data. Commented Nov 22, 2010 at 16:14

1 Answer 1

1

The Spring MVC application is a singleton. Every user accesses the same application. To do otherwise would be cripplingly bad for performance and scalability.

When you say "I am storing some data in a controller", do you mean storing request- or session-related data in field of the controller object? If so, then the default behaviour of Spring will cause problems for you, since everything is shared.

If you want to have such request- or session-private controller instances, then consider using scoped beans.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.