Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

Inconsistent path to files

Julie McCabe

2004-05-25

Replies:

Hello,

My setup is Tomcat 4.1.27, Java 1.4.2_02, Red Hat Linux 9.0.

I have a JSP located in the webapps directory I would like it to read a file
in the WEB-INF directory using a custom tag, eg,

File f = new File("WEB-INF/fileToRead.txt");

depending on which directory I start tomcat from the file will be located on
not - if I start tomcat from the $CATALINA_HOME directory it will work but if
I start tomcat from $CATALINA_HOME/webapps/webApp directory it will not pick
up the file because the location is wrong! I thought the code in the JSP
should work regardless of which directory tomcat is started from.

In addition, I have noticed the behaviour of the

<input type="file" is incorrect too

In the JSP with this tag, I am able to browse to the correct file but when the
upload is attempted I get a FileNotFoundException because it is looking for
$CATALINA_HOME/fileToUpload.txt - it ignores the path selected.

I am guessing this is a classpath problem or an environment variable that is
set when tomcat is started - I would appreciate any ideas on this.

Thanks,
Julie McCabe.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.