Results 1 to 5 of 5

Thread: Get a bean onto ServletContextScope

  1. #1

    Question 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. #2
    Join Date
    Aug 2009
    Location
    Wesley Chapel, FL
    Posts
    35

    Default

    I think you can do something like:

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

  3. #3

    Default

    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.

  4. #4
    Join Date
    Aug 2009
    Location
    Wesley Chapel, FL
    Posts
    35

    Default

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

  5. #5

    Default

    That, indeed, does what I need. Thank you!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •