users@jax-rpc.java.net

Re: Accessing the WebContext within a webservice

From: Pedro Salazar <pedro-b-salazar_at_PTINOVACAO.PT>
Date: Mon, 31 Mar 2003 08:39:30 +0100

Hi Julian,

When you try to read a file the default path is your web context root, I
mean the parent root of "WEB-INF" directory of you web application.

If your service implements the javax.xml.rpc.server.ServiceLifecycle
interface, you could read your file like this sample (here I got a
inputStream instead):

 public void init(Object object) {

        ServletEndpointContext sec=(ServletEndpointContext)object;
        ServletContext sc=sec.getServletContext();
        InputStream is =
sc.getResourceAsStream("WEB-INF/classes/a.txt");
        ...
}

I'm not sure if this answer your problem, but you could also try to read
your file through the classloader of your classfile. I don't know if
that would help you either.

regards,
Pedro Salazar.

On Sat, 2003-03-29 at 13:48, Julian Gantner wrote:
> hi list,
>
> i would like to access the webcontext in my webservice (currently
> using jaxrpc) in order to read a file to configure it. or how do i
> configure my webservice? i need to load some application specific
> informatiom from a configfile. when i put the file in the root, from
> where i start my tomcat, then the file can be read using
> java.io.FileReader(filename). But i would like to put that file
> (filename) in the directory where the webapplication resides. when i
> do this, then the configfile could not be found. can you give me a
> hint what to do?
>
> thank you very much.
>
> greetings, julian
>
> ____________________________________________________
> JULIAN GANTNER IT-L?sungen Winterstrasse 35
> Tel. +49.721.93 77 490 76137 Karlsruhe/Germany
> Fax. +49.721.93 77 489 www.itloesungen.com
> Mobil +49.179.39 76 156 kontakt_at_itloesungen.com
> PGP-Key : www.itloesungen.com/pgp/JulianGantner.asc
>
>
>
--
PS
pedro-b-salazar_at_ptinovacao.pt
PGP:0E129E31D803BC61