You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ashish Kulkarni <as...@gmail.com> on 2008/03/28 21:22:48 UTC
[OT] Read XML file from folder outside web application
Hi
I can use servletContext.getResource('/WEB-INF/myconfig.xml'); to read
myconfig.xml file which is under WEB-INF from a servlet
If i keep this file at c:/test/myconfig.xml file, can i read it from
a servlet, if so how??
Ashish
Re: [OT] Read XML file from folder outside web application
Posted by Martin Gainty <mg...@hotmail.com>.
place the myconfig.xml in WEB-INF/classes
then in struts.xml include that file
<include file="myconfig.xml"/>
M-
----- Original Message -----
From: "Ashish Kulkarni" <as...@gmail.com>
To: <us...@struts.apache.org>
Sent: Friday, March 28, 2008 3:22 PM
Subject: [OT] Read XML file from folder outside web application
> Hi
> I can use servletContext.getResource('/WEB-INF/myconfig.xml'); to read
> myconfig.xml file which is under WEB-INF from a servlet
> If i keep this file at c:/test/myconfig.xml file, can i read it from
> a servlet, if so how??
>
> Ashish
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [OT] Read XML file from folder outside web application
Posted by Antonio Petrelli <an...@gmail.com>.
2008/3/28, Ashish Kulkarni <as...@gmail.com>:
> Hi
> i did File f = new File(mypath); and it works
> What is the danger of doing so?
Sorry, I was a bit misleading. I meant that it is better not to expose
that file with an absolute path to the internet, as it can become a
backdoor to your server.
But, as long as you parse it internally in your code, I think there is
no danger.
Antonio
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [OT] Read XML file from folder outside web application
Posted by Ashish Kulkarni <as...@gmail.com>.
Hi
i did File f = new File(mypath); and it works
What is the danger of doing so?
Ashish
On 3/28/08, Antonio Petrelli <an...@gmail.com> wrote:
>
> 2008/3/28, Ashish Kulkarni <as...@gmail.com>:
>
> > I can use servletContext.getResource('/WEB-INF/myconfig.xml'); to read
> > myconfig.xml file which is under WEB-INF from a servlet
> > If i keep this file at c:/test/myconfig.xml file, can i read it from
> > a servlet, if so how??
>
>
> You can read it with a File object, giving the absolute path, but in a
> web application is very, very....... very very very dangerous!
>
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: [OT] Read XML file from folder outside web application
Posted by Antonio Petrelli <an...@gmail.com>.
2008/3/28, Ashish Kulkarni <as...@gmail.com>:
> I can use servletContext.getResource('/WEB-INF/myconfig.xml'); to read
> myconfig.xml file which is under WEB-INF from a servlet
> If i keep this file at c:/test/myconfig.xml file, can i read it from
> a servlet, if so how??
You can read it with a File object, giving the absolute path, but in a
web application is very, very....... very very very dangerous!
Antonio
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org