What is the simplest way to map a folder on the file system to a url in Tomcat?
- by Simon
Here's my problem... I have a small prototype app (happens to be in Grails hosted on AWS) and I want to add the ability of the user to upload a few (max 10) images. I want to persist these images on disk on the server machine, in a folder location which is outside my WAR.
I realise that there is probably a super-scalable solution involving more web servers and optimised static asset serving, but for the approximately 100 users I am likely to get, it's really not worth the effort and cost.
So, what is the simplest way I can have a virtual folder from my url map to a physical folder on disk? I sort of want...
http://myapp.com/static
to map to a folder which I can configure e.g.
/var/www/static
so I can then have in my code...
<img src="/static/user1/picture.jpg"/>
I don't particularly mind whether the resulting physical folders are directly browsable. Security will eventually be an issue, but it isn't at the start.
So, what are my options? I have looked at virtual hosts on the apache site, but it feels more complicated than I need.
I don't want to use the Grails static rendering plugins.