--- Zach Moazeni <[EMAIL PROTECTED]> wrote:
> Hello,
>
> In a Spring application that is being deployed to
> Tomcat I need to be able to load a file. The file
> resides in the /WEB-INF folder of the webapp. Is
> there any environmental variables I can be sure will
> be set so I can open a file relative to Tomcat?
> Things like "catalina.home" or "catalina.base", or
> is there a better alternative?
>
> Thanks for any and all input
> -Zach
You can get this information from your
ServletContext.getRealPath("/") and that will be the
directory of your web application context on the
server in which your web application is running. You
can also use other methods such as
YourServletClass.getResource("/your/package/YourServletClass.class")
and if in a jar file parse out the jar file path then
get it's parent or if it's a pure file URL then get
the parent of that file. I do that sometimes when
it's classes which can run in a web server or
standalone. Anyways, those are options that work.
Wade
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]