Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Difference between WebApplicationContext and ApplicationContext in SpringsMVC

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 387
    Comment on it

    Well, when we start off with SpringMVC first of all we have Dependency Injection in mind and then comes ApplicationContext but when we dig deep we get stuck with a lot of issues one of which is Difference between ApplicationContext and WebApplicationContext. Now we will discuss the root difference among the two aforesaid contexts in SpringMVC
    "The ApplicationContext includes all functionality of the BeanFactory, it is generally recommended over the BeanFactory. BeanFactory can still be used for light weight applications like mobile devices or applet based applications" "The Scopes that ApplicationContext shares are singleton and Prototype scopes and the WebApplicationContext add more sense to it by implementing the Application context and providing scopes like session,request,globalSession, if we do not specify the bean scope it would be singleton by default "

    Since WebApplicationContext implements Applicationcontext, is made with the javax.servlet.ServletContext, it can actually communicate to the container.

    public interface WebApplicationContext extends ApplicationContext {
        ServletContext getServletContext();
    }
    

    WebApplicationContext as compared to ApplicationContext can have multiple instances in a single web app.or can be rephrased as each DispatcherServlet associated with single WebApplicationContext. applicationcontextname-servlet.xml file is specific to the DispatcherServlet and a web application can have more than one DispatcherServlet configured to handle the requests. In aforesaid like cases,we can configure a separate context-servlet for each DispatcherServlet. But, applicationContext.xml will remain common for all the servlet configuration files. SpringsMVC will by default load file named context-servlet.xml from our webapp using the structure hierarchy as WEB-INF folder where context-servlet.xml is located and has the configuration name in web.xml.

    but ApplicationContext would be same in the app and would be used by the complete app all through the life cycle of app

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: