0

I am working on a website in java.

When I login to that website I have use_case to fetch images from other websites and show them in my website. But the problem is that I don't want to show images by just storing URL, because the URL may change and in that case images won't be displayed. So, I want to store or write the URL as an image in a location. This way, the next time when I login my website, I wll just fetch my image from that location.

So, my question is where to store these images. If I store images in Tomcat webapps folder then next time when I build my project that folder will be deleted.

  • @Zoain That makes no sense; you can store them in any number of ways, including on the filesystem--and I'd argue they *should* be stored on the file system. Just not in the web app directory. – Dave Newton Nov 28 '14 at 13:45
  • Thanks but can you tell me how to store images on filesystem – KrishnaMurariVijay Dec 05 '14 at 09:48

1 Answers1

1

Storing in tomcat webapps folder is not a good approach and will not suffice the purpose. Can't you use database for the same. And please elaborate I want to store or write the url as image in a location what do you mean by that.

  • One way is I store the url in database and used that url in my image src on jsp page.But if url wil chamge then the image won;t be displayed.So, what I want is I convert that url into image,i.e., create the image,that I know but the problem is where to store that image,so that my database contain only path of that image. – KrishnaMurariVijay Nov 27 '14 at 05:35
  • So your question is mainly to store images after fetching them from URL. You have to store images in database because the images might "n" in numbers and you can't store them even on server. **So first fetch all the images from the URL and then store them in database in any format you want to like in BLOB or any other. – Prakhar Asthana Nov 27 '14 at 05:40
  • thanks but can u suugest me a method to store image in database. – KrishnaMurariVijay Nov 27 '14 at 06:40
  • I got to know that storing the image in database is a bad practisce.So can you suggest any othat method like storing it as a physical file on server and only mentioning the path of the image in databse. – KrishnaMurariVijay Nov 27 '14 at 07:15
  • You can create a separate folder in the apache server where your .war file present or in doc folder of apache and store the images at this place . And URL's in the database. This folder will not get refreshed even after server is restarted. But you need to take care of memory use of the server. And if memory is not the constraint then it will work fine. – Prakhar Asthana Nov 27 '14 at 07:47