• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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: 8953
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

 
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic