aspose file tools*
The moose likes Spring and the fly likes Relation between ContextLoaderListener application context and WebApplicationContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Relation between ContextLoaderListener application context and WebApplicationContext" Watch "Relation between ContextLoaderListener application context and WebApplicationContext" New topic
Author

Relation between ContextLoaderListener application context and WebApplicationContext

Ganesha Kumar
Ranch Hand

Joined: May 04, 2006
Posts: 56
Hi all,
Suppose I create an application context using ContextLoaderListener. And I am using Spring MVC. The DispatcherServlet is also having its WebApplicationContext. What is the relationship between these two application contexts.

Thanks,
Ganesh
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
The WebApplicationContext of DispatcherServlet inherits the beans defined in the root WebApplicationContext.
You can read http://static.springsource.org/spring/docs/2.5.6/reference/mvc.html for more information.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Ganesha Kumar
Ranch Hand

Joined: May 04, 2006
Posts: 56
Are there 2 Spring containers one created by ContextLoaderListener and another by DispatcherServlets? If yes, then if the beans in the rootAppplicationContext are inherited by the WebApplicationApplication, do they live in 2 Containers?

Thanks,
Ganesh
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
From the documentation, yes. You can have a look at source code if you're really curious.
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684

The DispatcherServlet provides a gateway to the server and every request of the application workflow involved with HTTP-based request-response handling done by DispatcherServlet.

WebApplicationContext is a special type of context. And it is combine with dispatcher servlet and manages all components as controllers, mappings between URLs, and interceptors, views.

WebApplicationContext doesn't much difference from normal ApplicationContext.


Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Relation between ContextLoaderListener application context and WebApplicationContext
 
Similar Threads
ContextLoaderListener
Exception during application startup
How to register ContextLoaderListener ?
Spring MVC-How to get WebApplicationContext in Spring without ContextLoaderListener?
DispatcherServlet vs ContextLoaderListener?