Why is Tomcat trying to resolve relative paths to C:WINNTsystem32?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Russ_Weeks
Posted On:   Wednesday, February 12, 2003 01:51 PM

I understand that I can use ServletContext.getResource(...) to access files within my webapp, but that functionality is not always available to me. Some examples: 1. I've configured log4j to use a FileAppender, and specified the file "webapp.log". This file is created in C:WINNTsystem32, but I would like it to be created under my webapp's directory. 2. My webapp applies a stylesheet to transform some XML. The stylesheet is in my WebApp's root directory. It uses to include a stylesheet in the same directory. However, I get a FileNotFoundException saying "C:WINNTsystem32 lah.xsl" could not be found. Is there a way to tell my web app to resolve relative paths based on the web a   More>>

I understand that I can use ServletContext.getResource(...) to access files within my webapp, but that functionality is not always available to me. Some examples:



1. I've configured log4j to use a FileAppender, and specified the file "webapp.log". This file is created in C:WINNTsystem32, but I would like it to be created under my webapp's directory.



2. My webapp applies a stylesheet to transform some XML. The stylesheet is in my WebApp's root directory. It uses to include a stylesheet in the same directory. However, I get a FileNotFoundException saying "C:WINNTsystem32 lah.xsl" could not be found.



Is there a way to tell my web app to resolve relative paths based on the web application's root directory?



Any help appreciated...



Russ

   <<Less

Re: Why is Tomcat trying to resolve relative paths to C:WINNTsystem32?

Posted By:   James_Bayer  
Posted On:   Wednesday, February 12, 2003 02:15 PM

specifying the webapp directory for your log isn't necessarily the best idea. when you overwrite that one with a new .war, you could lose all of your log files. if you still want to do it, just specify the absolute path. instad of webapp.log, use c:\temp\webapp.log.

as for blah.xsl, the same issue is affecting you here. the current working directory for tomcat is c:winntsystem32, in order for you to change it, you have to alter the start up script or specify absolute paths in your app. you can do this more cleanly by passing the absolute path to your webapp as a property via a servlet init parameter. alternatively, you could package the xsl files up and refer to them using the getResourceAsStream(String name) of java.lang.Class.
About | Sitemap | Contact