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

Reading file

Monmohan Singh
Ranch Hand

Joined: Aug 02, 2002
Posts: 82
I want to read an XMl file that is placed somewhere in the web-root/WEB-INF/ folder in the deployed war on the server.
How can I read the file from here by dynamically getting the complete file path??
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12789
    
    5
Look at the api for the javax.servlet.ServletContext interface.
With a ServletContext there are several possibilities - getResourceAsStream is popular or you can getRealPath to get an absolute path String.
Bill
Monmohan Singh
Ranch Hand

Joined: Aug 02, 2002
Posts: 82
thanks a lot for the help
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Reading file