Get file in managed bean from context

Posted: April 25, 2014 in ADF Programmatically, File management
Tags: , , , ,

You should create a folder within your Web Content. Then copy your file manually there (go to c:/Oracle/MiddleWare/Jdeveloper/Jdev/myWork/YourApp/ViewController…). Back in JDeveloper refresh your application and you should see the new file inside your new folder. Then you refer to it simply as “/MyFolder/myfile.txt” or anything else.

In managed bean you can get this file as:

public ServletContext getContext() {
return (ServletContext)getFacesContext().getExternalContext().getContext();
}
ServletContext context = getContext();
InputStream fs = context.getResourceAsStream(“/Folder/file”);

Comments

Leave a comment