Search code examples
google-app-engineservletsaccess-denied

Access denied to resource file from java servlet


I am trying to access a resource file from a servlet but getting HTTP Error 500 - access denied:

File file = new File("//warChildFolder//myFile.txt");
InputStream is = new FileInputStream(file); // <--error on this line

I am on google-app-engine.

Any help appreciated!


Solution

  • Google App Engine docs talk about "white listing" a file. Is that in play here?

    I also wonder about this:

    File file = new File("//warChildFolder//myFile.txt");
    

    Doesn't the leading slash make this an absolute path?

    I'd try it like this:

    File file = new File("WEB-INF/warChildFolder/myFile.txt");
    

    Make the path relative to the WAR root and be explicit about WEB-INF.