InputStream stream = this.getClass().getResourceAsStream("sessionlog.csv");
The way you place the CSV file assumes that it will be in the same package as the current class, FileDownloadBean .
If it really is in the root directory of the package, then you better use:
InputStream stream = this.getClass().getResourceAsStream("/sessionlog.csv");
Or, if it is actually in another package, for example com.example , you should use:
InputStream stream = this.getClass().getResourceAsStream("/com/example/sessionlog.csv");
Or, if it is actually at the root of the public webcontent (where the /WEB-INF folder is also among all other web files), you should use:
InputStream stream = externalContext.getResourceAsStream("/sessionlog.csv");
(which, by the way, works great for WAR classes instead of this.getClass() )
Balusc
source share