Tomcat can't find my image file when generating HTML
Posted: 02. January 2009 23:13
Hi all,
I'm using Eclipse 3.4.1 with XAMPP/Tomcat and am trying to reference an image in a Java web project using the following code:
or
However, no matter where I try placing the test.jpg file, I just can't seem to reference it as I get a broken image. Here are a few of the places I've tried placing it:
* Directory (the project)
* Directory > resources
* Directory > WebContent
* Directory > WebContent > resources
Am I doing something wrong? If I manually try referencing the image from a browser, I just get the same main project page again:
While the default XAMPP/Tomcat setup appears to not use a specific port in the URL (per the Tomcat example files), Eclipse seems to use port 8080. My entire Eclipse workspace is under C:\Eclipse\workspace\Directory.
The Java project I'm working on works just fine, but I just cannot seem to find out how to reference external images or other files (CSS, XSL, etc).
Any help would really be appreciated! I'm a PHP developer by trade, so this is fairly frustrating.
Thanks,
- Matt
I'm using Eclipse 3.4.1 with XAMPP/Tomcat and am trying to reference an image in a Java web project using the following code:
- Code: Select all
out.println("<img src=\"test.jpg\">");
or
- Code: Select all
out.println("<img src=\"resources/test.jpg\">");
However, no matter where I try placing the test.jpg file, I just can't seem to reference it as I get a broken image. Here are a few of the places I've tried placing it:
* Directory (the project)
* Directory > resources
* Directory > WebContent
* Directory > WebContent > resources
Am I doing something wrong? If I manually try referencing the image from a browser, I just get the same main project page again:
- Code: Select all
localhost:8080/Directory/test.jpg
While the default XAMPP/Tomcat setup appears to not use a specific port in the URL (per the Tomcat example files), Eclipse seems to use port 8080. My entire Eclipse workspace is under C:\Eclipse\workspace\Directory.
The Java project I'm working on works just fine, but I just cannot seem to find out how to reference external images or other files (CSS, XSL, etc).
Any help would really be appreciated! I'm a PHP developer by trade, so this is fairly frustrating.
Thanks,
- Matt