• 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

Image is not getting displayed in web application html page

 
Ranch Hand
Posts: 145
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
are you following the proper syntax like



you have to give the proper path for the image also.
 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
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
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.
 
Greenhorn
Posts: 18
jQuery Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try jstl



JSTL
 
Nancy Antony
Ranch Hand
Posts: 145
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks All. I'll try.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am facing same problem. None of the suggestion worked for me. Someone let me know if any other solution worked
 
Bear Bibeault
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
Have you followed the instructions in the JSP FAQ for creating server-relative URLs that start with the context path?

If so, you'll need to show your work so we're not just guessing.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic