The servers.xml file is in the conf folder just below the folder where we have installed the tomcat example: tomcat6.0/conf or if we are using an IDE like eclipse we must go to the directory where the server configuration is normally in the same workspace with the name Servers (in eclipse).
Configuration example changing the server.xml of an eclipse IDE workspace. The application is called MY-APP.
<Host appBase="webapps" autoDeploy="true" name="localhost"
unpackWARs="true">
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs"
pattern="%h %l %u %t "%r" %s %b"
prefix="localhost_access_log."
suffix=".txt"/>
<Context docBase="/home/ubuntu/content/" path="/MY-APP/img"/>
<!-- all the files in folder are linked to MY-APP/img -->
<Context docBase="MY-APP"
path="/MY-APP"
reloadable="true"
source="org.eclipse.jst.jee.server:MY-APP"/>
</Host>
In this example, the server configured on port 8080 can already see the image I have in the folder /home/ubuntu/content/myimage.jpg from the url http://localhost:8080/MY-APP/img/myimage .jpg
If you put the / at the beginning in an apache tomcat it refers to the webapp/ROOT
you can use request.getContextPath() to get the context of your app, and put :
request.getContextPath() + /TemporaryImages/...
which will give you as a result:
/TemporalesImagenes/... if you are in ROOT or /webappname/TemporalesImagenes/...
Also another option you can reference a folder of static content, xml, logs, images, etc in the url of your application.
To do this you must add the docBase context property in your server.xml file called , example:
The servers.xml file is in the conf folder just below the folder where we have installed the tomcat example: tomcat6.0/conf or if we are using an IDE like eclipse we must go to the directory where the server configuration is normally in the same workspace with the name Servers (in eclipse).
Configuration example changing the server.xml of an eclipse IDE workspace. The application is called MY-APP.
In this example, the server configured on port 8080 can already see the image I have in the folder /home/ubuntu/content/myimage.jpg from the url http://localhost:8080/MY-APP/img/myimage .jpg
And in your HTML tag you would have: