title: Can someone explain the Spring web.xml file?
body: <p>I'm new to Java Enterprise and to Spring but I have a strong grasp of standard Java. I am looking through an existing web application project. The project uses Tomcat/Spring/Hibernate which I understand is fairly common. It also uses DWR for remote method invocations. I'm finding it somewhat difficult to separate responsibilities: what Tomcat is responsible for, what Spring is responsible for, how a request gets from one to the other, and how the major pieces of Spring fit together. I've read a great deal of documentation on Spring, particularly about beans and bean factory and am still in process of reading more. Any advice you guys have would be welcome, but I'll provide some specific questions.</p>
  
  <p>Question 1: Where does the web.xml fit into things (when is it used/called, and where is it called from)? </p>
  
  <p>Code sample 1:</p>
  
  <pre><code>    &lt;servlet&gt;
      &lt;servlet-name&gt;qrst&lt;/servlet-name&gt;
          &lt;display-name&gt;qrst Servlet&lt;/display-name&gt;
      &lt;servlet-class&gt;
          org.springframework.web.servlet.DispatcherServlet
      &lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  </code></pre>
  
  <p>What does the above snippet do (or, what does it cause to happen)? At some point in my web app qrst.jsp gets used; is it the DispatcherServlet that calls qrst.jsp using the servlet name? Else what is the significance of the servlet name? What is load on startup?</p>
  
  <p>Code sample 2:</p>
  
  <pre><code>&lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;
          /someLocation/some-servlet.xml
      &lt;/param-value&gt;
  &lt;/context-param&gt;
  </code></pre>
  
  <p>Links or explanation of what the above does? I can see from looking at the XML file that it contains bean definitions and I do understand what beans are and how they are used, but I don't know any other details about this and would like to.</p>
  
  <p>Code sample 3:</p>
  
  <pre><code>&lt;servlet&gt;
    &lt;servlet-name&gt;dwr-invoker&lt;/servlet-name&gt;
    &lt;display-name&gt;DWR&lt;/display-name&gt;
    &lt;servlet-class&gt;
          org.directwebremoting.servlet.DwrServlet
  &lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;classes&lt;/param-name&gt;
          &lt;param-value&gt;
              somepackage.someclass
          &lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  </code></pre>
  
  <p>From what I read about beans, I believe those init-param elements are just parameters that get set in the servlet's java class. What's the significance of the servlet name, and what about the load on startup? The web app somehow "knows" when an AJAX (dwr) call is happening versus when the web app is being loaded for the first time (when its loading for the first time it should use qrst.jsp). How does it know this? How does it decide to route the request to DWR instead of to qrst.jsp? Where does it do this?</p>
  
  <p>Thanks. </p>