You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Glenn McCall <gl...@gtajb.com> on 2007/08/20 07:49:13 UTC

Enable file downloads outside the application tree

Hi I have a bulletin board scenarion (i.e. people can download files =
that others have uploaded).

The easiest solution is to simply save the uploaded files within my =
application's directory tree (e.g. .../webapps/myapp/files or similar). =
The problem with this is that if I deploy a new version of the web app, =
any previously uploaded files are nuked with the rest of the old version =
as my new version is being deployed.

My preferred solution is (at this point) to map the path "/myapp/files" =
to another directory. To do this, I'm looking for a "mapping" entry to =
put into my web.xml that would map the /myapp/files path to a directory =
outside my tomcat server (e.g. /myapp/files -> /downloads or similar). =
Unfortunately I just can't seem to find anything that would allow this =
other than writing a servlet or creating a whole new application (I can =
specify this alternate directory in the <context ...> element via the =
docBase attribute) but it would be a whole new application and cause me =
problems elsewhere.

Can I achieve this with a "mapping" entry in my web.xml (or =
context.xml)? And if so, how? Ideally this would return "correct" real =
path for a call to ServletContext.GetRealPath ("myapp/files").

Thanks

Re: Enable file downloads outside the application tree

Posted by David Delbecq <de...@oma.be>.
If your OS allow it, use symbolic links + context->allowLinking=true
En l'instant précis du 20/08/07 07:49, Glenn McCall s'exprimait en ces
termes:
> Hi I have a bulletin board scenarion (i.e. people can download files =
> that others have uploaded).
>
> The easiest solution is to simply save the uploaded files within my =
> application's directory tree (e.g. .../webapps/myapp/files or similar). =
> The problem with this is that if I deploy a new version of the web app, =
> any previously uploaded files are nuked with the rest of the old version =
> as my new version is being deployed.
>
> My preferred solution is (at this point) to map the path "/myapp/files" =
> to another directory. To do this, I'm looking for a "mapping" entry to =
> put into my web.xml that would map the /myapp/files path to a directory =
> outside my tomcat server (e.g. /myapp/files -> /downloads or similar). =
> Unfortunately I just can't seem to find anything that would allow this =
> other than writing a servlet or creating a whole new application (I can =
> specify this alternate directory in the <context ...> element via the =
> docBase attribute) but it would be a whole new application and cause me =
> problems elsewhere.
>
> Can I achieve this with a "mapping" entry in my web.xml (or =
> context.xml)? And if so, how? Ideally this would return "correct" real =
> path for a call to ServletContext.GetRealPath ("myapp/files").
>
> Thanks
>
>   


-- 
http://www.noooxml.org/


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org