• 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

Parsing XML file from servlet

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to parse a XML file from /WEB-INF directory. I want to do it from a bean class which is instantiated in a servlet. What path I should give to parse this file ?
Document doc = db.parse("/abc.xml") or
Document doc = db.parse("/WEB-INF/abc.xml") ?
Thanks for the help
Shaju
 
shaju joseph
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any thoughts ?
If not /WEB-INF directory, what path I should give to parse a file from application's root directory ?
Thx
Shaju
 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
joseph,
First of all have you thought about ".."
Secondly, do you know there is a button on which U (and only you) can click to edit your previous post if you want ot update it.
Hope this help,
thomas,
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If ur webapp is a .war file use the following in ur servlet code
InputStream is = getClass().getResourceAsStream("/WEB-INF/abc.xml")
Document doc = db.parse(is) ;
---------------

Originally posted by shaju joseph:
I am trying to parse a XML file from /WEB-INF directory. I want to do it from a bean class which is instantiated in a servlet. What path I should give to parse this file ?
Document doc = db.parse("/abc.xml") or
Document doc = db.parse("/WEB-INF/abc.xml") ?
Thanks for the help
Shaju

 
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic