0

I have a servlet that upload file to my server in webcontent\Upload folder. But when I try to reach for example dmbtest.gif in that file like this : localhost:8080/Upload/dmbtest.gif it doesn't work. I can't get image.

Should I use get method of that servlet to show images?

Sahin Yanlık
  • 1,171
  • 2
  • 11
  • 21
  • `Java EE How can I get uploaded files` can get by downloading – Santhosh Apr 29 '14 at 09:04
  • no no I don't mean by download for example I'd like to show it in img tag , and I don't want to give real path – Sahin Yanlık Apr 29 '14 at 09:07
  • What webserver are you using? Is the upload folder inside your web application or otherwise made accessible? Did you try adding the context of your application to the url (I assume your application isn't registered under the `Upload` context)? – Thomas Apr 29 '14 at 09:08
  • @Thomas in fact I put my folder inside webcontent to be reachable , should I do something else ? I use tomcat – Sahin Yanlık Apr 29 '14 at 09:09
  • http://stackoverflow.com/questions/19139426/how-to-write-a-file-to-resource-images-folder-of-the-app – Pavel Apr 29 '14 at 09:15
  • @Pavel I think it should be alot easy. I have a web server, I have a folder and just an image inside it. Tomcat doesn't serve it ? – Sahin Yanlık Apr 29 '14 at 09:19
  • is it a JSF application? – Pavel Apr 29 '14 at 09:54
  • @Pavel no it is Jsp and I am using servlet to upload – Sahin Yanlık Apr 29 '14 at 10:39
  • do you have a direct access to the folder and check if the image was uploaded fine and it is working(you can open it with and image editor)? Probably, this is the problem. Or you have to change the access rights of the file. – Pavel Apr 29 '14 at 10:59
  • @Pavel I fix it but it is not what I wanted I put my Uploads folder inside Assets and that folder is reachable so it works. – Sahin Yanlık Apr 29 '14 at 11:06
  • Did you try it using your webcontext as well, e.g. something like `localhost:8080/myapp/upload_folder_relative_to_app_root/image.gif`? You need to at least use the webcontext to tell Tomcat in which application to look for the folder containing the image. – Thomas Apr 29 '14 at 13:29
  • @Thomas yes I did, but It doesn't worked outside of my Assets folder I don't know why but it has permission so I bring my upload folder inside it. – Sahin Yanlık Apr 29 '14 at 14:54

0 Answers0