carlos palma
carlos palma

Reputation: 844

adding image to eclipse web project

Well, this is embarrasing...I can't seem to be able to add a humble image to a java web project in eclipse. What I did was that I created a folder called images inside WebContent, and then tried adding it in two ways, directly pasting it and using add/file, and advanced, which basically asks for a route to the image insider the hard drive.

The HTML syntax is here:

<img border="0" src="WebContent/images/network.jpg"
     alt="Pulpit rock" width="304" height="228">

I tried it with and without WebContent. I am sure there's something I'm missing, but after a couple hours decided to get help.

Thanks in advance for any assistance.

Upvotes: 8

Views: 48077

Answers (2)

user1687079
user1687079

Reputation: 1

You have to add the image within the eclipse project structure for eclipse to package it and have it available on the webserver. Just having the image on your local file system doesn't work. To do this, drag and drop the file from your file system onto the eclipse project tree folder.

Upvotes: 0

Elemental
Elemental

Reputation: 7521

You should in general try to avoid absolute paths. Specifically I believe from a normal web project you should try something like:

<img border="0" src="images/network.jpg"
     alt="Pulpit rock" width="304" height="228">

Which works like a charm for me.

Upvotes: 7

Related Questions