Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

images don't appear outside local machine

 
Bryan Clauser
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know I am doing something wrong here, but can't figure out what it is...
I have tomcat configured with apache and everything works fine until I try using images with my JSP pages. The images show up fine when I hit the browser from the box that the web server resides on, but as soon as I access the web server from another box the images show up broken.
the img tag look like:
<img border="0" src="file:///usr/local/tomcat1/webapps/ROOT/WEB-INF/images/profile2.jpg" width="500" height="500">
I am not sure if it is the factor that when accessing the page from outside the local enviroment it has problems resolving the path and filename?
Any suggestions?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
src="file:///usr/local/tomcat1/webapps/ROOT/WEB-INF/images/profile2.jpg"

By using the file: protocol, you are telling the browser to look for the image on the local file system... which is why it works when the browser is on the same machine as the server, but not others.
You need to serve the image using the HTTP protocol just like the pages themselves (and for that to work, you'll need to move the image to a folder outside of the WEB-INF folder).
hth,
bear
[ February 17, 2003: Message edited by: Bear Bibeault ]
 
Bryan Clauser
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bear,
I moved the images directory to
/usr/local/tomcat1/webapps/ROOT/images/
now in the code if have tried
<center><p><img border="0" src="images/profile.jpg" width="500" height="500"></p></center>
and
<center><p><img border="0" src="http://localhost/images/profile.jpg" width="500" height="500"></p></center>
and this does not work on the local machine now. I will work on it later, have to go make a living...
 
Bryan Clauser
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I figured a couple of things out, but I am still not sure how to get my problem straightened out. I created an images directory under
/usr/local/apache2/htdocs/images
and put the images there, and I could then access the images from other machines which was my problem. Now I am trying to figure out how I would get an image directory under say
/usr/local/tomcat1/webapps/ROOT/images
to be resolved by apache when running so each web application would have its own image directory? any suggestions
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic