1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

showing images in web application

Discussion in 'Java' started by Juuno, May 10, 2009.

  1. Juuno

    Juuno New Member

    Joined:
    Feb 3, 2009
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    I have my web application in Java and I put my images in myapplication/WebContent/img.
    And I would like to load that image from my html and I called it with:

    HTML:
    <img src="${pageContext.request.contextPath}/img/myimage.jpg" width="200" height="100" alt="can't display image"/>
    
    and when I run my program, it only displays "can't display image"(alt) and no image. and when I right-click on that "can't display image" and copy image location, then it shows "http://localhost:8081/myapplication/myimage.jpg"

    as far as i check, the location and the file name is right. What's wrong with it?
    Thanks in advance.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    See the final HTML and see what is the output for

    <img src="${pageContext.request.contextPath}/img/myimage.jpg"
     

Share This Page