Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seam 2, how to get the servletcontext?

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.

like image 463
Phil Avatar asked Jan 19 '23 08:01

Phil


1 Answers

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().

like image 184
Tair Avatar answered Jan 29 '23 07:01

Tair