0

I'm trying to find an image in my JSF project. Here's my folder structure:

enter image description here

The image is inside the "imagesFedex" folder.

I'm trying to find its path like this:

String ctx = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath();

try {
    FileInputStream imagem = new FileInputStream(ctx + "/src/main/webapp/imagesFedex/nova_logorapidao2.png");
} catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

But it's throwing the filenotfound exception. I've read that the images goes inside the resources folder. Do I have to change its location? How can I get this path correctly?

Tiny
  • 27,221
  • 105
  • 339
  • 599
Joao Victor
  • 1,111
  • 4
  • 19
  • 39
  • To debug this problem, you should check the value of `ctx`. – Robin Krahl Jul 01 '15 at 12:27
  • @RobinKrahl the value of ctx is "/solis_web" – Joao Victor Jul 01 '15 at 12:29
  • You should know that the folder structure of your project in your IDE, is not the same as what's unbundled into the deployment folder of your application server. You should have a dedicated folder (that is *not* within your source tree) that holds assets and resources like images – kolossus Jul 01 '15 at 17:06

0 Answers0