I've written a little photo album servlet. Images can be uploaded and
they are saved to some external directory: /some/dir/photos.
I'd like to be able to access these photos using <img> tags, but don't
know how to access anything outside of the external directory. On the
other hand I don't want to save the images inside the webapps
directory as the photos will all be lost every time I redeploy the
app.
I've created a static dispatcher servlet to access the images, but
it's slower and seems to break browser caching. Thus I'd prefer to
just use <img src="..."> tags if possible.
Can anyone point me in the right direction here?
Thanks,
J
> I've written a little photo album servlet. Images can be uploaded and
> they are saved to some external directory: /some/dir/photos.
[quoted text clipped - 8 lines]
> it's slower and seems to break browser caching. Thus I'd prefer to
> just use <img src="..."> tags if possible.
If you use a servlet to serve them, then you get access control - direct
download and you have no control.
But if you want to go that route, then you need to get that image
directory served.
Either by Apache outside of Tomcat or by Tomcat. I believe that
you will need to add a new context to Tomcat to have Tomcat serve
them.
Arne
j - 29 Jan 2008 04:09 GMT
> > I've written a little photo album servlet. Images can be uploaded and
> > they are saved to some external directory: /some/dir/photos.
[quoted text clipped - 20 lines]
>
> Arne
Thanks much for providing some direction. After a little digging and
trial-and-error, I was able to add the directory as a context and can
now use <img> tags they way I wanted.
umacts@gmail.com - 14 Mar 2008 21:48 GMT
> > > I've written a little photo album servlet. Images can be uploaded and
> > > they are saved to some external directory: /some/dir/photos.
[quoted text clipped - 26 lines]
>
> - Show quoted text -
Hi,
I have the same problem. Can you please explain what you did and how
you added a new context path?
Thanks
Uma
Gilbert Rebhan - 14 Mar 2008 22:09 GMT
/*
> I have the same problem. Can you please explain what you did and how
> you added a new context path?
>
> Thanks
> Uma
*/
You have to create a context in the
%TOMCAT_HOME%/conf/web.xml, see=
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
Regards, Gilbert