J
jsguru72
I have a personal web site that I use to view family pictures and
such. I have a database that stores the file name and I keep all of
the images in a sub-directory under WEB-INF so that they are not
directly accessible. I then use a servlet to check for a valid login
and forward the request to the WEB-INF directory.
I.E.
Images stored in WEB-INF/private
User requests /myapp/image/fileabc.jpg
Servlet mapped to 'image' checks for valid login, then forwards
request to WEB-INF/private/fileabc.jpg
This works okay, but I have 2 problems with this solution.
1) I am storing data in WEB-INF, where it really does not belong.
2) The web application is huge because it is bloated with all of these
image files.
To me, the images are data and should be stored somewhere else. The
problem is I cannot find an existing solution that lets me load an
image from outside the application context.
I would like to store the images in something like D:\images and then
use a servlet to get the filename from the database and return the
image from the D:\images path.
The only solutions I have seen are to write a servlet that streams the
image file to the web page. I can go this route, but I wasn't sure if
there was a better alternative. To me anyway, this seems like a
problem that would be fairly common. I mean Flickr and YouTube
certainly do not store all of their media within the application
directories.
There may be something really obvious that I am overlooking so before
I start writing a servlet to stream my images, I figured I would run
this by the experts.
Any thoughts or ideas would be appreciated.
Thanks.
such. I have a database that stores the file name and I keep all of
the images in a sub-directory under WEB-INF so that they are not
directly accessible. I then use a servlet to check for a valid login
and forward the request to the WEB-INF directory.
I.E.
Images stored in WEB-INF/private
User requests /myapp/image/fileabc.jpg
Servlet mapped to 'image' checks for valid login, then forwards
request to WEB-INF/private/fileabc.jpg
This works okay, but I have 2 problems with this solution.
1) I am storing data in WEB-INF, where it really does not belong.
2) The web application is huge because it is bloated with all of these
image files.
To me, the images are data and should be stored somewhere else. The
problem is I cannot find an existing solution that lets me load an
image from outside the application context.
I would like to store the images in something like D:\images and then
use a servlet to get the filename from the database and return the
image from the D:\images path.
The only solutions I have seen are to write a servlet that streams the
image file to the web page. I can go this route, but I wasn't sure if
there was a better alternative. To me anyway, this seems like a
problem that would be fairly common. I mean Flickr and YouTube
certainly do not store all of their media within the application
directories.
There may be something really obvious that I am overlooking so before
I start writing a servlet to stream my images, I figured I would run
this by the experts.
Any thoughts or ideas would be appreciated.
Thanks.