0

I've intialized a variable in ServletContext listener using the following code:

sce.getServletContext().setAttribute("foo", "someValue");

So, I can now get the value using following code:

FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get("foo");

Now, I want to access this value in some other class that is not a FacesContext, or is not a controller. How can I do that?

S1LENT WARRIOR
  • 11,254
  • 4
  • 42
  • 59
wasimbhalli
  • 4,798
  • 8
  • 42
  • 61

1 Answers1

1

If the other class is not running in FacesContext or ServletContext, then you simply can't.

Just pass it as constructor or method argument.

otherClass.doSomething(foo);
BalusC
  • 1,040,783
  • 362
  • 3,548
  • 3,513