Sometimes it makes more sense to serve static content like images to your website from a folder on the disk on your server rather than packaging it into a war file. To serve static content from tomcat7, you don’t need to write any java code or create a war file. You can simply edit the $TOMCAT_HOME/conf/server.xml and add <Context path=”/images” docBase=”/home/ubuntu/images” /> tag to the <Host> tag present in the file. path refers to the url path relative to the host/context and docBase refers to the location on disk. So if you have a url like /images/1.jpg, having the file /home/ubuntu/images/1.jpg will render the image.
If you have a war file and are creating a custom servlet, then you will also need to map the url pattern /images/* to the default servlet in web.xml file.
Additionally, the folder on the disk should have the right permissions to allow read access by tomcat.