Results 1 to 4 of 4
  1. #1
    Juuno is offline Member
    Join Date
    Feb 2009
    Posts
    18
    Rep Power
    0

    Default showing image in web application

    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:

    XML Code:
    <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 "//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. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    1. What web application are you talking about? JSP or anything else?

    2. You are using ordinary HTML tag there. So what's the connection between my first question?

  3. #3
    Juuno is offline Member
    Join Date
    Feb 2009
    Posts
    18
    Rep Power
    0

    Default

    Acutally, I wrote that code in my header.html file and I call it from my JSP using <%@ include file="header.html" %>.

    Thanks!

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    That make sense lol. ;)

    Ok, seems to me that the error is with the image path. First of all to make sure that the issue is related with the path, use the full image path and see.

    Can you explain a bit what are you going to do with the following.

    Java Code:
    ${pageContext.request.contextPath}

Similar Threads

  1. showing records in Jtable
    By Shivraj in forum NetBeans
    Replies: 0
    Last Post: 03-21-2009, 08:16 AM
  2. Showing
    By bostonstate in forum New To Java
    Replies: 3
    Last Post: 08-25-2008, 08:49 PM
  3. Need Help showing text in JTextArea
    By GuyFawkes in forum AWT / Swing
    Replies: 3
    Last Post: 05-05-2008, 10:19 AM
  4. Why isn't this showing?
    By JToolTip in forum Java Applets
    Replies: 2
    Last Post: 07-08-2007, 12:54 AM
  5. Showing Images with J2ME
    By luisarca in forum CLDC and MIDP
    Replies: 0
    Last Post: 06-18-2007, 11:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •