• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

images don't appear outside local machine

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic