Until now I used to think that a web-application can have only one dispatcher-servlet which we define in web.xml
- Am I right in thinking so?
- Can i have multiple dispatcher servlets in a single web application? If yes, How?
- What is a situation we might need this in?
- Can there only be a single application context in the entire web application?
- How can we define multiple application contexts?
- Can a
dispatcher-servletexist in a non-spring application?
Of course, quoting the official documentation (bold is actually there as well!)
Just declare several servlets with different names but using
org.springframework.web.servlet.DispatcherServletclass. Also make sureyourServletName-servlet.xmlfile is available.DispatcherServletis very flexible. Not only Spring MVC uses it, but also Spring WS, Spring support for hessian, etc.Answered already, also in the quoted documentation: one application context per
DispatcherServlet+ one main web application context.See above, just create multiple
DispatcherServlets.DispatcherServletis a Spring context (Spring application) on its own, thus: no. On the handDispatcherServletcan be declared in an application not having parent (main) application context, thus: yes.