Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] URI

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: luca <passani AT eunet.no>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] URI
  • Date: Mon, 05 Apr 2004 23:20:41 +0200


thanks for your help. Things seem to work now:

//sc is instance of ServletContext
String path = sc.getRealPath("/WEB-INF/somexmlfile.xml");
File file = new File(path);
if (file.exists()) {
obj = new Obj(file.toURI().toString());
}

this ends up in an invokation of :

parser.build(file.toURI().toString());

Hope this helps others in the future.
Extra keywords for the archive: servlet, ServeletContext, tomcat,
web application, webapp, getResource(), getResourceAsStream()


luca

Elliotte Rusty Harold wrote:

At 11:01 AM +0200 4/5/04, luca wrote:

thanks, is there an API to do the encoding?

I reported the expanded path, but my real problem is that
I am building a web-application
and I'll need to read my config XML file out of /WEB-INF/,
which I can achieve through ServletContext().getRealPath("/WEB-INF/myfile.xml").

Also, will I need to append the "file:///" string at the beginning?


It depends on what ServletContext().getRealPath("/WEB-INF/myfile.xml") gives you. I'm not personally familiar with that method, but I suspect File.toURI() or File.toURL might be what you're looking for.






Archive powered by MHonArc 2.6.24.

Top of Page