• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple contexts

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an MVC enabled application that has a single dispactcher servlet with it's springapp-servlet.xml configuration file.
I am trying to get my head around the syntax I hear people use. For instance does this single servlet along with it's xml cfg file amount to what people call a context? I assume I can have more than one dispatcher servlet with an accompanying cfg file so in that case is that an application with multiple contexts?
Basically I'm trying to understand web applications from a high level before really getting into the nuts and bolts of the business logic and navigation, requests, responses etc
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

james frain wrote:I have an MVC enabled application that has a single dispactcher servlet with it's springapp-servlet.xml configuration file.
I am trying to get my head around the syntax I hear people use. For instance does this single servlet along with it's xml cfg file amount to what people call a context? I assume I can have more than one dispatcher servlet with an accompanying cfg file so in that case is that an application with multiple contexts?
Basically I'm trying to understand web applications from a high level before really getting into the nuts and bolts of the business logic and navigation, requests, responses etc



Yes, you can have multiple contexts. And in the case of Spring MVC, you want two contexts. One for just the web layer beans and one for the middle tier services/repositories. The middle tier one becomes the Parent context of the Web Layer's child context. Which means the child context can see any beans in the parent context. but the parent context cannot see the child context. You want to inject Services into your Controllers, but you definitely never want to inject a Controller into a Service. Call down the stack not up.

Hope that helps

Mark
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic