Announcement Announcement Module
Collapse
No announcement yet.
Get a bean onto ServletContextScope Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get a bean onto ServletContextScope

    What's the easiest way for me to get a bean onto "Web Application scope" - I think ServletContextScope in Spring - so that I can reference it globally via direct JSTL EL like ${lookupMap} ?

  • #2
    I think you can do something like:

    Code:
    servletContext.setAttribute("lookupMap", lookupMapInstance);

    Comment


    • #3
      Yes, but there's no natural place in my application for such code to reside. It would be much more natural to specify that scope in the bean configuration or web.xml.

      Otherwise I have to subclass ContextLoaderListener or inject these beans into some other web-aware bean which wouldn't naturally be the "owner" of such data.

      Comment


      • #4
        Right. Sorry for the misunderstanding. Maybe org.springframework.web.context.support.ServletCon textAttributeExporter will work for you?

        Comment


        • #5
          That, indeed, does what I need. Thank you!

          Comment

          Working...
          X