2 Replies - 1749 Views - Last Post: 24 August 2013 - 05:09 PM

#1 hrishih100  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-January 13

images are not displaying except in IE and apache tomcat

Posted 22 August 2013 - 07:38 AM

I am developing project using servlet html css in eclipse. Images are displaying in IE and tomcat but not in any other browser.but when I copied html code into notepad and tried to run then images are displaying in all browsers. Images are stored in web content folder of eclipse.
and i am using img tag as :
<img src="file:///D:/Workspace/Auction/WebContent/paint1.jpg" />
Is This A Good Question/Topic? 0
  • +

Replies To: images are not displaying except in IE and apache tomcat

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4399
  • View blog
  • Posts: 12,255
  • Joined: 18-April 07

Re: images are not displaying except in IE and apache tomcat

Posted 22 August 2013 - 10:23 AM

You should not put a hard coded file path link to a local image file in your HTML. You should always be working with a full URL or a relational path. Simple tip for you there.

When you run it in a browser where the image does not show up, have you checked for errors in the developer console of that browser? For instance, in Chrome if you run the page and then right click the missing image and select "Inspect Element" and then select the "Console" tab, do you see any error messages there related to the image? You probably will see something like image not found or chrome might be blocking it for some reason.

:)
Was This Post Helpful? 0
  • +
  • -

#3 Pogaca  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 43
  • Joined: 24-August 13

Re: images are not displaying except in IE and apache tomcat

Posted 24 August 2013 - 05:09 PM

Let me explain you something. If you have local file (Image) in some folder keep this in mind. Imagine you have your HTML file called index.html in FOLDER called Website. Now that folder Website have so far nothing but your index.html file. Now, imagine you create another folder inside your Website folder, and it's called Images. Now, you add inside that folder image called Image1.jpg . How can you use that image inside your index.html web page? Very simple. Keep it in mind that if you want to call some image from local files not public URL, you will have to ask yourself question: "Is image I am looking for in the same folder as my index.html page?". The answer is NO. Why? Well it's not directly in the same folder as index.html but it's in other folder called Images. So how to obtain image now? Here is example how:
<img src="Images/image1.jpg">

As you can see, I type only the name of the folder where is Image but not whole path as you do above. Always ask yourself : "Where is my index.html file?" . And when you know where it is , just locate the image with this simple way. What can happen if the image was directly in the same folder as index.html file? Well we can type in like this then:
<img src="image1.jpg">

You can see now how we don't go into folder, but just locating him right there. Keep it also in mind that if your image is saved in folder before Website folder, then you will have to enter full path as you did, but until then, keep images in same folder as your index.html page. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1