Meaningless Drivel is fun!*
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Reading file" Watch "Reading file" New topic

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

Joined: Mar 22, 2000
Posts: 12761
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.
Monmohan Singh
Ranch Hand

Joined: Aug 02, 2002
Posts: 82
thanks a lot for the help
jQuery in Action, 2nd edition
subject: Reading file
Similar Threads
Reading file attributes from local file system
Properties file path hard coded
Need Advice on Global Configuration
about xml files use
Reading a File in a JSF project.