• 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 not getting displayed

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am developing a Struts project using myeclipse IDE. In this I have developed a JSP page using struts tags. I want to insert an image on this page. For doing this I have used these two options:

1. <html:img src="images/struts-power.gif" />
2. <html:img align="" alt="" border="" page="/images/struts-power.gif"

Also note that, i have used all the possible permutation/combinations for the image path. So there is no possibility of using a wrong root. It seems that there is some other configuration error

The directory structure of my application is CMSystem/WebRoot/images/...
CMSystem/WebRoot/WEB-INF/... The context is CMSystem folder.

But, none of the above is showing the image on viewing in browser. I am using JBOss 3.2.5.

Please let me know what mistake I am doing.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my view html:image tag doesn't offer you any advantages over the plain html version <img>. I'd just use the html version.

In my experience, a problem with getting images to display usually is due to a disconnect between where in the directory structure your current page is coming from, and where the image is coming from.

One surefire way to avoid this is to go back to the context root and then out the tree from there. However, in order to avoid hard coding the context root name in the application, it's better to represent it with the value request.getContextPath().

So, I'd try the following:

<img src="<%=request.getContextPath() %>/images/myImage.gif" >
 
Jitendra Kumar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem has been solved. Thanks everyone for your responses.

Solution: myeclipse ide was not packing the image file while deploying on to Jboss. It created new image folder and put the image file again in that and it worked.It was a silly mistake, I should have checked it earlier.
reply
    Bookmark Topic Watch Topic
  • New Topic