• Post Reply Bookmark Topic Watch Topic
  • New Topic

Path to config file

 
Matt Phipps
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Sorry for the newbie question, I'm sure the answer is obvious but I can't find it...

I have a config.xml file in WEB-INF (next to web.xml and struts-config.xml) and I need to pass this files location to a commons digester program (reads in xml files). The digester program needs the full path and file name. If i put the file in c:\temp\config.xml it works fine but how do I find the path to /WEB-INF/config.xml when the app is deployed? Is there a standard method I can call to give me the path to my web app?

Thanks for your help,
Matt
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ServletContext.getRealPath()
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may also want to consider passing the digester program a stream.
ServletContext.getResourceAsStream(String).
This eliminates the need to rely on the server's file system path and makes your app more portable.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!