|
|
tomcat - access files outside of webapp
I've written a little photo album servlet. Images can be uploaded andthey are saved to some external directory: /some/dir/photos.I'd like to be able to access these photos using <img> tags, but don'tknow how to access anything outside of the external directory. On theother hand I don't want to save the images inside the webappsdirectory as the photos will all be lost every time I redeploy theapp.I've created a static dispatcher servlet to access the images, butit's slower and seems to break browser caching. Thus I'd prefer tojust use <img src="..."> tags if possible.Can anyone point me in the right direction here?Thanks,J
|
|
0
|
|
|
|
Reply
|
jrhite (2)
|
1/29/2008 2:43:21 AM |
|
j wrote:> 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 - directdownload and you have no control.But if you want to go that route, then you need to get that imagedirectory served.Either by Apache outside of Tomcat or by Tomcat. I believe thatyou will need to add a new context to Tomcat to have Tomcat servethem.Arne
|
|
0
|
|
|
|
Reply
|
ISO
|
1/29/2008 2:48:03 AM
|
|
On Jan 28, 9:48 pm, Arne Vajh=F8j <a...@vajhoej.dk> wrote:
> j wrote:
> > 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=3D"..."> 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
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.
|
|
0
|
|
|
|
Reply
|
jrhite (2)
|
1/29/2008 4:09:11 AM
|
|
On Jan 28, 11:09=A0pm, j <jrh...@gmail.com> wrote:
> On Jan 28, 9:48 pm, Arne Vajh=F8j <a...@vajhoej.dk> wrote:
>
>
>
>
>
> > j wrote:
> > > I've written a little photo album servlet. =A0Images can be uploaded a=
nd
> > > 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. =A0On t=
he
> > > 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. =A0Thus I'd prefer to
> > > just use <img src=3D"..."> 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
>
> Thanks much for providing some direction. =A0After 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
|
|
0
|
|
|
|
Reply
|
umacts
|
3/14/2008 8:48:13 PM
|
|
/*
> 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
|
|
0
|
|
|
|
Reply
|
Gilbert
|
3/14/2008 9:09:08 PM
|
|
|
4 Replies
767 Views
(page loaded in 0.006 seconds)
|
|
|
|
|
|
|
|
|