I have 3 "contextual" files for my web application. One is web.xml, One is context.xml, and another is dispatcher-servlet.xml. Note I've to use Spring for my web app. I have a single web application which needs to run on the server. Can someone verify my understanding ?
1. Web.xml - needed and must have for all java web apps. This is where the servlet configuration goes in. What are the parameters param-name = contextConfigLocation and contextLoaderListener and why are they needed ? What does a contextLoaderListener do exactly ?
<context-param>
<description>Spring Application Context Configuration</description>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext-workflow.xml
/WEB-INF/applicationContext-general.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.mvc</url-pattern>
</servlet-mapping>
Context.xml is for environment specific db connections, queue connections go. Is using commons dbcp the preferred choice ?
And the dispatcher-servlet.xml looks like this: Why does it need to be like this ?
In terms of these files being loaded by the server, will context.xml be loaded first, then web.xml then dispatcher-servlet.xml ?
In terms of a client request, will it first be intercepted by dispatcher-servlet ?