You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Barry BURNEREAU <bb...@sqli.com> on 2004/02/14 14:40:58 UTC

Geting a file in WEB-INF from a web service

Hello

I'm adding some web service to an existing webapp written with servlet.
There is a configuration file in the web-inf directory. I'd like to read 
this configuration file in the web service.

In the servlet, I use servletcontext.getResourceAsStream(path).

How could i do similar thing in the web service ?

Thanks

Barry



Re: Geting a file in WEB-INF from a web service

Posted by Barry BURNEREAU <bb...@sqli.com>.
Thanks a lot

It's exactly what i want.

Barry

At 16:09 14/02/2004, you wrote:
>Hi Barry,
>
>// Get path to WEB-INF
>org.apache.axis.MessageContext msgContext =
>org.apache.axis.MessageContext.getCurrentContext();
>String strWebInf =
>msgContext.getProperty(org.apache.axis.transport.http.HTTPConstants.MC_HTTP_
>SERVLETLOCATION).toString();
>
>// Use path to WEB-INF to read text file into properties
>Properties propsConfig = new Properties();
>propsConfig.load(new BufferedInputStream(new FileInputStream(new
>File(strWebInf + "/Config.txt"))));
>
>// Use path to WEB-INF to read text file into string
>BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new
>File(strWebInf + "/Stuff.txt")));
>ByteArrayOutputStream baos = new ByteArrayOutputStream();
>int nData = bis.read();
>while (nData != -1)
>{
>     baos.write(nData);
>     nData = bis.read();
>}
>bis.close();
>baos.flush();
>baos.close();
>String strStuff = baos.toString();
>
>
>Jeff
>
>
>
>----- Original Message -----
>From: "Barry BURNEREAU" <bb...@sqli.com>
>To: <ax...@ws.apache.org>
>Sent: Saturday, February 14, 2004 8:40 AM
>Subject: Geting a file in WEB-INF from a web service
>
>
> > Hello
> >
> > I'm adding some web service to an existing webapp written with servlet.
> > There is a configuration file in the web-inf directory. I'd like to read
> > this configuration file in the web service.
> >
> > In the servlet, I use servletcontext.getResourceAsStream(path).
> >
> > How could i do similar thing in the web service ?
> >
> > Thanks
> >
> > Barry
> >



Re: Geting a file in WEB-INF from a web service

Posted by Jeff <je...@cogentlogic.com>.
Hi Barry,

// Get path to WEB-INF
org.apache.axis.MessageContext msgContext =
org.apache.axis.MessageContext.getCurrentContext();
String strWebInf =
msgContext.getProperty(org.apache.axis.transport.http.HTTPConstants.MC_HTTP_
SERVLETLOCATION).toString();

// Use path to WEB-INF to read text file into properties
Properties propsConfig = new Properties();
propsConfig.load(new BufferedInputStream(new FileInputStream(new
File(strWebInf + "/Config.txt"))));

// Use path to WEB-INF to read text file into string
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new
File(strWebInf + "/Stuff.txt")));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int nData = bis.read();
while (nData != -1)
{
    baos.write(nData);
    nData = bis.read();
}
bis.close();
baos.flush();
baos.close();
String strStuff = baos.toString();


Jeff



----- Original Message ----- 
From: "Barry BURNEREAU" <bb...@sqli.com>
To: <ax...@ws.apache.org>
Sent: Saturday, February 14, 2004 8:40 AM
Subject: Geting a file in WEB-INF from a web service


> Hello
>
> I'm adding some web service to an existing webapp written with servlet.
> There is a configuration file in the web-inf directory. I'd like to read
> this configuration file in the web service.
>
> In the servlet, I use servletcontext.getResourceAsStream(path).
>
> How could i do similar thing in the web service ?
>
> Thanks
>
> Barry
>