reset password
Author Message
alzayer13
Posts: 9
Posted 12:40 Feb 06, 2015 |
My lab4 work well on the localhost but it doesn't work in server I always get this 
FileNotFoundException: images/gaga.png (No such file or directory), 

               FileInputStream in = new FileInputStream("images/gaga.png" );

 

this the file input ?? where I should put my image in server? I put them in WWW folder but I am not sure 

 

Wael
Posts: 2
Posted 12:47 Feb 06, 2015 |

Create a folder of images inside WWW and the link of images will be: 

../images/FileName.png

alzayer13
Posts: 9
Posted 13:35 Feb 06, 2015 |

still have  the same error 

java.io.FileNotFoundException: ../images/gaga.png (No such file or directory)
hippiewho
Posts: 46
Posted 14:30 Feb 06, 2015 |

try                FileInputStream in = new FileInputStream("../images/gaga.png")

giraid
Posts: 39
Posted 14:37 Feb 06, 2015 |

try single dot instead: ./images/FileName.png

if it does not work, you need some code to find your current path, some thing like

String path = request.getSession().getServletContext().getRealPath("/");

and put the image folders under www/lab4,

then the path to the image is path + "lab4/images/" + "gaga.png".

I found the code online, and I documented it as such, I think you should probably do the same if you choose to use it.

edit: by webcontent, I meant www/

Last edited by giraid at 14:40 Feb 06, 2015.
alzayer13
Posts: 9
Posted 14:52 Feb 06, 2015 |

I tried this and it finally works. 

               FileInputStream in = new FileInputStream("../www/images/gaga.png" );

Thank you.

Last edited by alzayer13 at 20:20 Feb 06, 2015.
hippiewho
Posts: 46
Posted 18:15 Feb 06, 2015 |

I thought we weren't supposed to use absolute paths