Announcement Announcement Module
No announcement yet.
ApplicationContext Hierarchy Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • ApplicationContext Hierarchy

    In a web application, when you have multiple separate contexts, for example a global context loaded by a Listener and several servlet contexts, what are the rules governing how the parent-child hierarchy is established?

    I spent a few hours searching the docs and the web, and was unable to find a definitive answer. There's an answer on StackOverflow ( that says Spring sets this up, but gives no details.

    Is this documented anywhere?

  • #2
    Spring indeed sets this up.

    The dispatcherservlet detects the context loaded by the contextloaderlistener and uses that as a prent for its own applicationcontext. Each dispatcherservlet has its own applicationcontext which has the one from the contextloaderlistener as a parent. Detection is done based on name as it is stored in the ServletContext.