• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parsing XML file from servlet

 
shaju joseph
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Thomas Smets
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • 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,
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic