aspose file tools*
The moose likes Servlets and the fly likes Parsing XML file from servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Parsing XML file from servlet" Watch "Parsing XML file from servlet" New topic
Author

Parsing XML file from servlet

shaju joseph
Ranch Hand

Joined: Jun 28, 2001
Posts: 30
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

Joined: Jun 28, 2001
Posts: 30
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

Joined: Dec 11, 2001
Posts: 111
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,


Thomas Smets
Just another developper
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

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


Groovy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parsing XML file from servlet
 
Similar Threads
Dynamic File Path
Help with parsing an xml string java
Reading xml file
How to pass a parsed XML Document object from servlet to JSP??
Can and How do you pass a Document Object from servlet to a JSP