Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8289683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:33:59+00:00 2026-06-08T12:33:59+00:00

What is the difference between Application Context and Web Application Context? I am aware

  • 0

What is the difference between Application Context and Web Application Context?

I am aware that WebApplicationContext is used for Spring MVC architecture oriented applications?

I want to know what is the use of ApplicationContext in MVC applications? And what kind of beans are defined in ApplicationContext?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:34:00+00:00Added an answer on June 8, 2026 at 12:34 pm

    Web Application context extended Application Context which is designed to work with the standard javax.servlet.ServletContext so it’s able to communicate with the container.

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

    Beans, instantiated in WebApplicationContext will also be able to use ServletContext if they implement ServletContextAware interface

    package org.springframework.web.context;
    public interface ServletContextAware extends Aware { 
         void setServletContext(ServletContext servletContext);
    }
    

    There are many things possible to do with the ServletContext instance, for example accessing WEB-INF resources(xml configs and etc.) by calling the getResourceAsStream() method.
    Typically all application contexts defined in web.xml in a servlet Spring application are Web Application contexts, this goes both to the root webapp context and the servlet’s app context.

    Also, depending on web application context capabilities may make your application a little harder to test, and you may need to use MockServletContext class for testing.

    Difference between servlet and root context
    Spring allows you to build multilevel application context hierarchies, so the required bean will be fetched from the parent context if it’s not present in the current application context. In web apps as default there are two hierarchy levels, root and servlet contexts: Servlet and root context.

    This allows you to run some services as the singletons for the entire application (Spring Security beans and basic database access services typically reside here) and another as separated services in the corresponding servlets to avoid name clashes between beans. For example one servlet context will be serving the web pages and another will be implementing a stateless web service.

    This two level separation comes out of the box when you use the spring servlet classes: to configure the root application context you should use context-param tag in your web.xml

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/root-context.xml
                /WEB-INF/applicationContext-security.xml
        </param-value>
    </context-param>
    

    (the root application context is created by ContextLoaderListener which is declared in web.xml

    <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener> 
    

    )
    and servlet tag for the servlet application contexts

    <servlet>
       <servlet-name>myservlet</servlet-name>
       <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
       <init-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>app-servlet.xml</param-value>
       </init-param>
    </servlet>
    

    Please note that if init-param will be omitted, then spring will use myservlet-servlet.xml in this example.

    See also: Difference between applicationContext.xml and spring-servlet.xml in Spring Framework

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Difference between Activity Context and Application Context I want to know the
What is the difference between System.Web.HttpContext.Current.User.Identity.Name and System.Environment.UserName in the context of a ASP.Net
A standard spring web application (created by Roo or Spring MVC Project Template) create
A have a little confuse the difference between Widget Context and Application Context :
In the context of url matching in java web applications, what is the difference
In context of WAS, what is the difference between application bounce and jvm bounce.
I maintain a web application that is outgrowing a single VPS. The architecture consists
What's the difference between application layer and business logic layer? I kind of understand
What is the difference between awk and sed ? What kind of application are
What is the difference between debug and compile? How do I compile an application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.