You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by IBM partner Gestione Elaboratori <ca...@gmail.com> on 2012/09/11 09:11:46 UTC
how to read files in file system
With jsp i can read files in the file system only if there are located under
the directory webapps/<application>/<file>.
If I read a file ,for example, in c:/<filename> Tomcats signals an error (se
atthachment)
How to read files located everywere in the file system?
paoloc
Re: R: how to read files in file system
Posted by "mailinglist@j-b-s.de" <ma...@j-b-s.de>.
Try:
URI uri = new URI("file//c:/.."); // win
Or
"file:///yourdir/.." on unix (note 3 "/").
From uri you can get the url and from here you can open an inputstream or you can use "new File(url.toFile())"
To access a resource from your classpath the following will do:
URL url = Thread.currentThread().getContextClassloader().getResource("relativeNameOfFile");
Basically this should work, but its untested as my phone does not provide a java compiler :-)
Jens
Sent from my iPhone
On 18.09.2012, at 08:21, "Ge Gestione Elaboratori\(IBM Business Partner\)" <ca...@gmail.com> wrote:
> Excuse me Dan:
> attached the screenshot.
> paolo
>
> -----Messaggio originale-----
> Da: Daniel Mikusa [mailto:dmikusa@vmware.com]
> Inviato: martedì 11 settembre 2012 13.51
> A: Tomcat Users List
> Oggetto: Re: how to read files in file system
>
> On Sep 11, 2012, at 3:11 AM, IBM partner Gestione Elaboratori wrote:
>
>> With jsp i can read files in the file system only if there are located
> under
>> the directory webapps/<application>/<file>.
>>
>> If I read a file ,for example, in c:/<filename> Tomcats signals an error
> (se
>> atthachment)
>
> Again, there is no attachment. The list is probably removing it. Please
> try pasting the content into your email.
>
> Please also include the error that is given. Without that, we can only
> guess at what is happening.
>
> Dan
>
>> How to read files located everywere in the file system?
>>
>>
>>
>> paoloc
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: R: how to read files in file system
Posted by Pid * <pi...@pidster.com>.
On 18 Sep 2012, at 07:22, "Ge Gestione Elaboratori(IBM Business
Partner)" <ca...@gmail.com> wrote:
> Excuse me Dan:
> attached the screenshot.
Zeesh.
Stop attaching it, paste some info inline in the message and stop being lazy.
p
> paolo
>
> -----Messaggio originale-----
> Da: Daniel Mikusa [mailto:dmikusa@vmware.com]
> Inviato: martedì 11 settembre 2012 13.51
> A: Tomcat Users List
> Oggetto: Re: how to read files in file system
>
> On Sep 11, 2012, at 3:11 AM, IBM partner Gestione Elaboratori wrote:
>
>> With jsp i can read files in the file system only if there are located
> under
>> the directory webapps/<application>/<file>.
>>
>> If I read a file ,for example, in c:/<filename> Tomcats signals an error
> (se
>> atthachment)
>
> Again, there is no attachment. The list is probably removing it. Please
> try pasting the content into your email.
>
> Please also include the error that is given. Without that, we can only
> guess at what is happening.
>
> Dan
>
>> How to read files located everywere in the file system?
>>
>>
>>
>> paoloc
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
R: how to read files in file system
Posted by "Ge Gestione Elaboratori(IBM Business Partner)" <ca...@gmail.com>.
Excuse me Dan:
attached the screenshot.
paolo
-----Messaggio originale-----
Da: Daniel Mikusa [mailto:dmikusa@vmware.com]
Inviato: martedì 11 settembre 2012 13.51
A: Tomcat Users List
Oggetto: Re: how to read files in file system
On Sep 11, 2012, at 3:11 AM, IBM partner Gestione Elaboratori wrote:
> With jsp i can read files in the file system only if there are located
under
> the directory webapps/<application>/<file>.
>
> If I read a file ,for example, in c:/<filename> Tomcats signals an error
(se
> atthachment)
Again, there is no attachment. The list is probably removing it. Please
try pasting the content into your email.
Please also include the error that is given. Without that, we can only
guess at what is happening.
Dan
> How to read files located everywere in the file system?
>
>
>
> paoloc
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: how to read files in file system
Posted by Daniel Mikusa <dm...@vmware.com>.
On Sep 11, 2012, at 3:11 AM, IBM partner Gestione Elaboratori wrote:
> With jsp i can read files in the file system only if there are located under
> the directory webapps/<application>/<file>.
>
> If I read a file ,for example, in c:/<filename> Tomcats signals an error (se
> atthachment)
Again, there is no attachment. The list is probably removing it. Please try pasting the content into your email.
Please also include the error that is given. Without that, we can only guess at what is happening.
Dan
> How to read files located everywere in the file system?
>
>
>
> paoloc
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: how to read files in file system
Posted by Martin Gainty <mg...@hotmail.com>.
//in ${catalina.base}/conf/catalina.policy
//grant the containing jar (read and write) FilePermission to folder named 'filename' located off of root
//if the jar (containing the class which will access filename folder) is tomcat-juli.jar
grant codeBase "file:${catalina.base}/bin/tomcat-juli.jar" {
{
permission java.io.FilePermission "${file.separator}filename${file.separator}*", "read, write";
};
Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> From: casemie@gmail.com
> To: users@tomcat.apache.org
> Subject: how to read files in file system
> Date: Tue, 11 Sep 2012 09:11:46 +0200
>
> With jsp i can read files in the file system only if there are located under
> the directory webapps/<application>/<file>.
>
> If I read a file ,for example, in c:/<filename> Tomcats signals an error (se
> atthachment)
>
> How to read files located everywere in the file system?
>
>
>
> paoloc
>