Kathleen Angeles wrote:What happens to the images in memory if you restart your server? Are you going to reload all images from the db during the startup of the server?
It sounds like reinventing the cache system.
You may opt to use a cache implementation out there (e.g. ehcache).
Paul Clapham wrote:I don't see why you should be implementing a cache for these images when you could perfectly well make use of the caching feature of the browsers who access your application.
You can override the "long getLastModified(HttpServletRequest req)" method of the servlet which returns the image to return the time that the image was uploaded; this will cause browsers to cache the image.
Paul Clapham wrote:I see, I didn't read your original post carefully enough. So you didn't write a servlet to handle requests for the uploaded images. Did you consider doing that and reject that on the basis that you could somehow persuade the container to handle those requests? You might find that writing the image-serving servlet makes many of your questions go away, or at least allows you to reformulate them into something which is easier to answer.
Jayesh A Lalwani wrote:
If you are serving static images, your best bet is always going to be to store them on the file system, and serve them up right through Apache.