This content has been marked as final.
Show 4 replies
-
1. Re: Seeking best way to get docRoot from the application con
norman.richards Jan 9, 2007 9:27 AM (in response to datagazetteer)Do you mean the UIViewRoot for the page?
-
2. Re: Seeking best way to get docBase from the application con
datagazetteer Jan 9, 2007 9:46 AM (in response to datagazetteer)Sorry, no -- I didn't type the exact name of what I'm looking for and that is undoubtedly a source of confusion. What I need is the best way to get the /docBase/ -- otherwise known as the "Context Root" according to the Tomcat documentation:
The Document Base (also known as the Context Root) directory for this web application, or the pathname to the web application archive file...http://tomcat.apache.org/tomcat-5.5-doc/config/context.html#Common%20Attributes
-
3. Re: Seeking best way to get docRoot from the application con
gavin.king Jan 9, 2007 11:22 AM (in response to datagazetteer)Use the JSF ExternalContext object.
-
4. Re: Seeking best way to get docRoot from the application con
datagazetteer Jan 9, 2007 12:08 PM (in response to datagazetteer)Ah, I think I see. Something like this?
import javax.faces.context.FacesContext; import javax.servlet.ServletContext; FacesContext facesContext = FacesContext.getCurrentInstance(); ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext(); String docBase=servletContext.getRealPath(".");
Thanks, Gavin.