• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to specify the path for DocumentBuilder.parse

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to parse a xmlfile deployed as in war file contained within an ear file
The file is parsed within a JSP. The filename is provided as an init parameter. Now I need to provide the path along with the filename in the call DocumentBuilder.parse(filename).
If the full path is hardcoded in the string "filename" there is no problem however I cannot hardcode the path of the file.
thanks in advance
Navjeet
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you use Class#getResource(String name) and URL#toString() to get the path to your file inside the .ear/.war?
 
Navjeet Nehra
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lasse,
I tried to specify the same however it did not work. Maybe I am not doing it properly. Anyhow I have temporarily solved the problem using the following
parser.parse(this.getClass().getResourceAsStream(PARAM_FILE));
and ensuring that the file lies in a directory which is in the CLASSPATH.
However if you can elaborate on your suggestions it would be of great help.
thanks
Navjeet
reply
    Bookmark Topic Watch Topic
  • New Topic