File creation in the web applications' root  
Author Message
sasuke





PostPosted: 2007-12-12 1:30:00 Top

java-programmer, File creation in the web applications' root Hello all.

Is it possible to get the path at which my application root is placed
by means of either the ServletContext or the ServletConfig object?

What I am trying to do here is to dynamically create a Javascript file
on the fly and put in the script directory of my web application. But
since the working directory in a web applications case is the
directory which contains the app servers' executable, any new file
created would be created there and I don't want to hard code the path
to my script folder. I want everything to be relative to the
applications' root as far as possible.

Can it be done without any special configuration, the way I can get a
resource present in the application root by the getResource() method?
Any kind of help would be greatly appreciated.

Regards,
sasuke.
 
Andrew Thompson





PostPosted: 2007-12-12 7:59:00 Top

java-programmer >> File creation in the web applications' root sasuke wrote:
..
>Is it possible to get the path at which my application root is placed
>by means of either the ServletContext or the ServletConfig object?

<http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/ServletContext.html#getRealPath(java.lang.String
)>

--
Andrew Thompson
http://www.physci.org/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200712/1

 
sasuke





PostPosted: 2007-12-12 23:12:00 Top

java-programmer >> File creation in the web applications' root On Dec 12, 4:58 am, "Andrew Thompson" <u32984@uwe> wrote:
> sasuke wrote:
>
> ..
>
> >Is it possible to get the path at which my application root is placed
> >by means of either the ServletContext or the ServletConfig object?
>
> <http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/Servle...
> )>

Thank you, really appreciated.