Ayush
Ayush

Reputation: 119

How many containers in spring MVC?

I am new to spring. I wanted to know two things :

  1. Does the Dispatcher Servlet and ApplicatonContext exists in two different containers (in terms of spring).
  2. Also, if they are part of same container, then how is it possible that spring is creating two beans if I scan the classes in both of their config files?

Will be very thankful for any help.

Upvotes: 0

Views: 517

Answers (1)

Siddharath Mehra
Siddharath Mehra

Reputation: 11

SpringMVC has one Container i.e WebApplicationContext(Interface)

A Context represents your environment. It represents the state surrounding where you are in your system. For example, in web programming in Java, you have a Request, and a Response. These are passed to the service method of a Servlet. A property of the Servlet is the ServletConfig, and within that is a ServletContext. The ServletContext is used to tell the servlet about the Container that the Servlet is within. So, the ServletContext represents the servlets environment within its container. Similarly, in Java EE, you have EBJContexts that elements (like session beans) can access to work with their containers.(copy/paste from qoura)

Upvotes: 1

Related Questions