title: Role/Purpose of ContextLoaderListener in Spring?
body: <p>I am learning <em>Spring Framework</em> which is being used in my project. I found the  <strong><em>ContextLoaderListener</em></strong> entry in my <em>web.xml</em> file. But could not figure out how exactly it helps a developer?</p>
  
  <p>In the official documentation of <a href="http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/context/ContextLoaderListener.html"><em>ContextLoaderListener</em></a> it says  it is to start <em>WebApplicationContext</em>. Regarding <a href="http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/context/WebApplicationContext.html"><em>WebApplicationContext</em></a> JavaDocs say:</p>
  
  <blockquote>
    <p>Interface to provide configuration for a web application.</p>
  </blockquote>
  
  <p><br>
  But I am not able to understand what I am achieving with <em>ContextLoaderListener</em> which internally initializes the <em>WebApplicationContext</em> ?</p>
  
  <p><strong>As per my understanding</strong>, <em>ContextLoaderListener</em>  reads the Spring configuration file (with value given against contextConfigLocation in <em>web.xml</em>), parses it and loads the <em>singleton bean</em> defined in that config file. Similarly when we want to load <em>prototype bean</em>, we will use same webapplication context to load it. So we initialize the webapplication  with <em>ContextLoaderListener</em> so that we read/parse/validate the config file in advance and whenever we wan to inject dependency we can straightaway do it without any delay. Is this understanding correct?</p>