tomcat - access files outside of webapp

J

j

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
 
A

Arne Vajhøj

j said:
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.

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

j

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

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.
 
U

umacts

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.- Hide quoted text -

- 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top