title: Understanding contexts in Spring MVC
body: <p>I am new to spring and I am creating a simple web application. I have been reading about contexts in Spring MVC. </p>
  
  <p>I am using STS plugin for eclipse. I created a
  Spring MVC project using the plugin. </p>
  
  <p>Now I have three xml documents in the project, web.xml, root-context.xml and servlet-context.xml. These were created by STS for me. </p>
  
  <ol>
  <li><p>In web.xml, dispatcher servlet is pointed towards servlet-context.xml and I understand the dispatcher servlets job is to create a web application context which knows how to resolve views and is a place for controller beans to exist. 
  Is my understanding correct? If so, what other job is accomplished by this context? </p></li>
  <li><p>Now, there is a file called root-context.xml which has a component scan on my projects default package. My understanding is this context needs to have global beans which many servlets might use. Is my understanding correct? What else does this do? What kind of context is created using this file? </p></li>
  <li><p>Now, I am further along in the project and I have several *-context.xml files (dao-context.xml, security-context.xml etc) which are loaded using contextLoaderListner (in web.xml). Is this a good idea? Or should everything go into servlet-context.xml? I think it's a good idea to have different contexts as it provides separation of concern. Comments? Also, what kind of context is created from these *-context.xml files? What is the proper folder location for these files? </p></li>
  <li><p>Web.xml is for the servlet container like tomcat etc and all other xml files in the project are for the spring container. Is that correct? All these files are separated to provide separation of concern? </p></li>
  <li><p>How many application contexts and web application contexts exists in the current scenario? </p></li>
  </ol>
  
  <p>Why would anyone need more than one dispatcher servlet? </p>
  
  <p>Why would anyone need more than one application context? </p>
  
  <p>Thoughts? Comments? Corrections? Best practices? </p>