Results 1 to 5 of 5
  1. #1
    Mateo1041 is offline Member
    Join Date
    Dec 2008
    Posts
    4
    Rep Power
    0

    Question Eclipse can't find my image file when generating HTML

    Hi all,

    I'm trying to reference an image in a Java web project using the following code:

    Java Code:
    out.println("<img src=\"test.jpg\">");
    or
    Java Code:
    out.println("<img src=\"resources/test.jpg\">");
    However, no matter where I try placing the test.jpg file, I just can't seem to reference it as I get a broken image. Here are a few of the places I've tried placing it:

    • Directory (the project)
    • Directory > resources
    • Directory > WebContent
    • Directory > WebContent > resources


    Am I doing something wrong? If I manually try referencing the image from a browser, I just get the same main project page again:

    Java Code:
    ocalhost:8080/Directory/test.jpg
    I'm working with Eclipse 3.4.1 and using XAMPP + Tomcat in a Windows XP Pro SP3 environment. The Java project I'm working on works just fine, but I just cannot seem to find out how to reference external images or other files (CSS, XSL, etc).

    Any help would really be appreciated! I'm a PHP developer by trade, so this is fairly frustrating.

    Thanks,
    - Matt

  2. #2
    Mateo1041 is offline Member
    Join Date
    Dec 2008
    Posts
    4
    Rep Power
    0

    Default

    Anyone? :-(

  3. #3
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default Display jpg

    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  4. #4
    Mateo1041 is offline Member
    Join Date
    Dec 2008
    Posts
    4
    Rep Power
    0

    Default

    Thanks, but what about if I'm just trying to display the image via generated HTML, such as via XSLT through the Saxon library?

  5. #5
    Mateo1041 is offline Member
    Join Date
    Dec 2008
    Posts
    4
    Rep Power
    0

    Default

    I got this to work. My trouble with displaying external files such as images was due to a combination of things, most noticeably not fully understanding the web.xml file, how Tomcat structures things, nor the proper URL to use.

    apachefriends.org/f/viewtopic.php?f=16&t=32649

Similar Threads

  1. How can I include a html file in html textarea?
    By surya_dks in forum New To Java
    Replies: 2
    Last Post: 10-04-2008, 07:20 AM
  2. To open an image file such as Jpeg file using JAva Program
    By itmani2020 in forum Advanced Java
    Replies: 10
    Last Post: 07-11-2008, 09:57 AM
  3. Generating Javadoc In Eclipse IDE
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 05-22-2007, 09:34 PM
  4. Replies: 1
    Last Post: 04-26-2007, 03:52 PM
  5. Using Find And Replace In Eclipse IDE
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 04-26-2007, 10:15 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
  •