• Post Reply Bookmark Topic Watch Topic
  • New Topic

Access a file into web-inf folder  RSS feed

 
Steeve Randria
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Steeve Randria
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!