Reputation: 50386
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.
Upvotes: 5
Views: 3353
Reputation: 3809
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()
.
Upvotes: 10