Gaurav Sandil wrote:I mean to say that I have seen some code where they have used applicationContext.xml and DispatcherServlet.xml(usually Servlet name follwed by-servlet.xml) and seen some examples where they used only one.
What are the uses of these two xml files.
Cool, that makes more sense.
So with you have xxx-servlet-xml, that typically has just the Web Layer beans.
The applicationContext.xml has the middle tier beans like your services and repositories, as well as importing the xml files that have your infrastructure beans like dataSource and transactionManager.
Each of these files is actually loaded by different classes making two different ApplicationContext instances. One for the middle tier beans and one for the web layer beans which separates them in a good way. The Web Layer will have full access to beans in the middle tier, but not the other way around. But you do not want your middle tier to see any beans from your web layer.
You should be able to call down the stack, but not up.
When you have seen it where they only have one file and one loading of the application context, those people are just not separating out the layers. You can do this and everything works, but I personally don't recommend it.
Mark