- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference between DispatcherServlet and ContextLoaderListener in Spring
ContextLoaderListener creates a root web-application-context for the web-application and puts it in the ServletContext. This context can be used to load and unload the spring-managed beans ir-respective of what technology is being used in the controller layer(Struts or Spring MVC).
DispatcherServlet creates its own WebApplicationContext and the handlers/controllers/view-resolvers are managed by this context.
|1||Basic||The task of the DispatcherServlet is to send request to the specific Spring MVC controller ||ContextLoaderListener reads the Spring configuration file (with value given against contextConfigLocation in web.xml ), parses it and loads the singleton bean defined in that config file. So we initialize the web application with ContextLoaderListener so that we read/parse/validate the config file in advance and whenever we can to inject dependency we can straightaway do it without any delay|
|2||Optional||It is optional. Spring application can’t live without the DispatcherServlet||It is mandatory. Spring application can live without the ContextLoaderListner|
|3||Container|| DispatcherServlet creates its own WebApplicationContext. The handlers/controllers/view-resolvers are managed by this context||Application Context is the container initialized by a ContextLoaderListener defined in the web.xml|
|4||Beans|| Web-specific beans such as controllers are included in DispatcherServlet’s Web Application Context||General beans such as services and DAOs make their way in root Web Application Context|
- Difference between applicationContext.xml and spring-servlet.xml in Spring Framework
- Difference between Spring AOP and AspectJ AOP
- Difference between Save and SaveAndFlush in Spring Java
- Difference between IOC and Dependency Injection in Spring.
- Difference between @Bean and @Component annotation in Spring.
- Difference between Application context and Beanfactory in Spring framework
- Difference Between Constructor Injection and Setter Injection in Spring
- Difference between JDK dynamic proxy and CGLib proxy in Spring
- Spring Boot Actuator A Production Grade Feature in Spring Boot
- Difference between !== and ==! operator in PHP
- Difference between . and : in Lua programming
- Difference between C# and .Net
- Difference between Process and Thread
- Difference between Concurrency and Parallelism