You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Diego Ezquerro <d....@yahoo.com> on 2007/09/17 16:33:26 UTC

Relative paths in my webapp

Hi to everyone.

I'm developing a webapp and need to store some files and use some images stored in my project dir but, I have a problem with the relative paths on my app.

If I write a file in using:

                File f = new File(someFileName);
                f.createNewFile();
                FileOutputStream fos=new FileOutputStream(f);
                fos.write(fileData,0,fileSize);
                fos.flush();
                fos.close();
 
it's stored in netbeans-5.5.1/enterprise3/apache-tomcat-5.5.17/bin instead of my project root directory.

And if I try to use an image with:

    <img src="../images/collapsedMidNode.gif" border="0"/>

then the file isn't found, and I must use absolute paths in both cases.

How can i solve this??
Isn't the root directory of the project the one who contains WEB-INF and META-INF directories?

Thanks so much for the answers.



Diego Ezquerro Bailac
Asturias, Spain



__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.espanol.yahoo.com/ 

Re: Relative paths in my webapp

Posted by andrea <an...@sardiniapoint.it>.
hi, Diego

you have to put the images under the webRoot/images  folder...

Andrea

----- Original Message ----- 
From: "Diego Ezquerro" <d....@yahoo.com>
To: "struts" <us...@struts.apache.org>
Sent: Monday, September 17, 2007 4:33 PM
Subject: Relative paths in my webapp


Hi to everyone.

I'm developing a webapp and need to store some files and use some images 
stored in my project dir but, I have a problem with the relative paths on my 
app.

If I write a file in using:

                File f = new File(someFileName);
                f.createNewFile();
                FileOutputStream fos=new FileOutputStream(f);
                fos.write(fileData,0,fileSize);
                fos.flush();
                fos.close();

it's stored in netbeans-5.5.1/enterprise3/apache-tomcat-5.5.17/bin instead 
of my project root directory.

And if I try to use an image with:

    <img src="../images/collapsedMidNode.gif" border="0"/>

then the file isn't found, and I must use absolute paths in both cases.

How can i solve this??
Isn't the root directory of the project the one who contains WEB-INF and 
META-INF directories?

Thanks so much for the answers.



Diego Ezquerro Bailac
Asturias, Spain



__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
Regístrate ya - http://correo.espanol.yahoo.com/ 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org