aspose file tools
The moose likes Java in General and the fly likes Access a file into web-inf folder Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Access a file into web-inf folder" Watch "Access a file into web-inf folder" New topic
Author

Access a file into web-inf folder

Steeve Randria
Greenhorn

Joined: Sep 17, 2010
Posts: 16
Hello,

How can I access a file in the WEB-INF please?
My file is located in WEB-INF/xmlFiles/exemple.xml and I access via / example.xml into my program.



But this method works only on my own server JBoss, if I test on the production server, it no longer works because it can not find the file



Thanks a lot
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

You should always use ServletContext's getRealPath method for resolving any paths relative to the web application to actual paths that you can use with File, FileInputStream, etc.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Steeve Randria
Greenhorn

Joined: Sep 17, 2010
Posts: 16
Hello,

Thanks for your answer!
The problem that is I'm not in a servlet, but a simple POJO, so I can not call the ServletContext
It 's possible to know the path dynamically?

thanks a lot
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Access a file into web-inf folder
 
Similar Threads
Problem starting servlet
files in WEB-INF/classes not found?
path to applicationContext.xml
Web hoster
passing file over a wire