• Post Reply Bookmark Topic Watch Topic
  • New Topic

Image is not getting displayed in web application html page  RSS feed

 
Nancy Antony
Ranch Hand
Posts: 145
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I created a web application using eclipse and jboss.

I created a simple html page to display image. I stored .html file and .jpg file in webcontent and wrote this code





when I run the application thru server i.e. run on server, text on the page gets displayed but there is no image displayed.

where to place the images and how to refer it in html.

Regards,
Nancy
 
Gokul Nanthakumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are you following the proper syntax like



you have to give the proper path for the image also.
 
Nicola Garofalo
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the source of your img tag could follow the following pattern




What is the source of your image tag, and what is the context-root of your web application?
 
Nancy Antony
Ranch Hand
Posts: 145
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nicola,

My context path is /JSLab. I created an images folder in JSLab and placed my .jpg file there.
and I tried <img src=/JSLab/images/flowers3.jpg"></img> But its not diplaying.

What changes I need to make?

Regards,
Nancy
 
Nicola Garofalo
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nancy,
unfortunately i don't have any other answers. What i wrote is a common server-relative url, and it should work.

The only thing i can suggest you is to verify the names of your folder, file, context path, and the letters case,
For example in your post there's a syntax error
<img src=/JSLab/images/flowers3.jpg"></img>

Write your line as follows:


Did you create your images folder under your webcontent folder, didn't you?

Did you rebuild your project after the changes you made to your path?

Hope it helps.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Server-relative URLs are the only way to go and will work if the syntax is correct and the folder layout is as you say.

What URL works to display the image directly in the browser?

Also, be sure not to hard-code the context path. Obtain it programmatically. This is covered in the JSP FAQ.
 
Ernesto Chicas
Greenhorn
Posts: 18
Debian Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try jstl



JSTL
 
Nancy Antony
Ranch Hand
Posts: 145
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks All. I'll try.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!