1

I have a folder called attachments in my webapps folder in my Apache Tomcat directory, in which I need to save some files and images. When I'm giving the local path i.e. in C:/ the files needed are being saved in the correct location.

However I need to load these images from the server at runtime so I'm trying to access the image by the localhost url /attachments/img.png. The image is not being found (404 error).

I tried opening Tomcat's manager to see if attachments is listed. It is there however when I click it a 404 error is being thrown too. Other deployed web applications are being found.

What could be the cause of this?

Bernice
  • 2,552
  • 11
  • 42
  • 74
  • This guy seemed to be trying to do the same thing, may be worth reading: http://stackoverflow.com/questions/417658/how-to-config-tomcat-to-serve-images-from-an-external-folder-outside-webapps – Kyle Jul 18 '13 at 13:38

1 Answers1

0

You cannot just create a folder in $CATALINA_HOME/webapps like this and access it from web browser.

webapps folder is supposed to be home for all web applications with proper J2EE web app like directory structure e.g. WEB-INF/web.xml, WEB-INF/classes, WEB-INF/lib, META-INF etc.

Read more about Web Application Directory Stricture

anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Thanks for your answer but I am still confused since yesterday I did the same exact things and tomcat did recognize the folder and the images were in fact loaded! – Bernice Jul 18 '13 at 13:37
  • You can leverage [Virtual Webapp in Tomcat 7](http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Virtual_webapp) or see some answers in the provided link by @Kyle – anubhava Jul 18 '13 at 13:42