I am trying to understand basic Spring MVC stuff.
Consider the web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Also consider below diagram that is given in the official docs:
Doubts:
- What is precise types of instances created by
DispatcherServletandContextLoaderListener? The confusion arise, since some articles online sayContextLoaderListenercreatesApplicationContextinstance andDispatcherServletcreatesWebApplicationContextinstance. But, after looking at their source, I feel both create instance of typeWebApplicationContext, and since its subtype ofApplicationContext, some articles sayContextLoaderListenercreatesApplicationContextinstance. Is it also the case that onlyApplicationContext-provided functionalities of instance created byContextLoaderListenerare used, and hence the article sayContextLoaderListenercreatesApplicationContext, but notWebApplicationContext` Is it like the
WebApplicaionContextcreated byContextLoaderListeneris what usually online articles refer to as "root"WebApplicationContext, just to differentiate it fromWebApplicationContexts created byDispatcherServlet?Reading this article, I understood that
DispatcherServletloads from[servlet-name]-servlet.xmlfile which should load "web tier components". On the other handContextLoaderListenerloads "middle tier components". Given that there can be only oneContextLoaderListenerin web.xml (right?), there should be only single single set of "middle tier components", whereas, since there can be multipleDispatcherServlets, there can be multiple sets of "web tier components". Is this right? If so, then why the above diagram shows multipleWebApplicationContexts of middle tier components and singleWebApplicationContextof web tier component?

WebApplicationContextandApplicationContextare interfaces, so when documentation says "createsApplicationContextinstance" it means that it creates an object instance of a class that implementsApplicationContext. Whether that class also implementsWebApplicationContextis besides the point. It may. It may not. Doesn't invalidate the statement that it "createsApplicationContextinstance".XmlWebApplicationContext? Also can you answer the other two questions...or they are senseless?