Seam 2, how to get the servletcontext?
Asked Answered
O

1

5

I'm in seam 2. How can I get the servlet context?

I can do this: ServletContexts servletContexts = ServletContexts.getInstance();

But this is not the ServletContext.

Ostia answered 2/7, 2011 at 5:39 Comment(0)
C
10

Depending at what moment you are trying to get the ServletContext:

  • During a HttpServletRequest request: ServletContexts.instance().getRequest().getServletContext().

  • During JSF request: (ServletContext)FacesContext.getCurrentInstance().getExternalContext().

  • During application startup: ServletLifecycle.getServletContext().

Cementation answered 3/7, 2011 at 11:2 Comment(1)
Should be FacesContext.getCurrentInstance()Ceremony

© 2022 - 2024 — McMap. All rights reserved.