Mapping a directory outside the web-app to URL in TOMCAT

imagejakarta-ee

I need to map an directory containing images which resides outside tomcat webapps folder, so that application can serve those images.

I am making a J2EE Web application running under tomcat 6. User can upload/delete images in the application. Currenly I store these images to a directory under application's WebContent folder, but I want to take it outside the tomcat (e.g. C:/test/images).

I need to know how to I configure tomcat so that if I access URL http://.com/images/abc.jpg , it serves the image from directory C:/test/images

Thanks,

Best Answer

Add a <Context> tag in server.xml, inside the <Host> tag:

<Context path="/images" docBase="C:/test/images/" />

Docs will be accessible at http://localhost:8080/images

Related Topic