Results 1 to 7 of 7

Thread: displaying an image

  1. #1

    Default displaying an image

    hello all,

    this question is so simple....i really didnt want to have to post the question here, but ive been searching google and the forums with no quick answer or tutorial.

    how do i display an image?? i thought simple html: img src="file.jpg"

    but this does not work. im thinking i must make a bean called imageSource or something like this in a bean, but havent been able to find any examples.

    thanks in advance,
    vincent disco

  2. #2
    Join Date
    Aug 2004
    Location
    The Netherlands
    Posts
    160

    Default

    What are you trying to do? Where do you want this image display to occur? I guess as normally in the jsp? What is the problem with a normal <img /> tag? Please provide us with more details as to what you are trying to accomplish and provide us some code of what you allready have.
    Jettro Coenradie
    http://www.gridshore.nl

  3. #3

    Default it could have been that simple...

    is the correct way to display an image in a .jsp:

    <img src="file.jpg"/> ?

    i was actually just using normal html: <img src="file.jpg"> and could have been missing the forwardslash at the end....tomorrow i will be able to test it.

  4. #4
    Join Date
    Aug 2004
    Location
    The Netherlands
    Posts
    160

    Default

    No that should not be necessary, the backward slash is just to make it xhtml compliant. So this should not be your problem. You could try to load the image direct:

    http://<servername>:<port>/<appname>/file.jpg

    have a look at your war file and see if your image is in the war file.
    Jettro Coenradie
    http://www.gridshore.nl

  5. #5

    Default where should the image be?

    my filesystem is like this:

    ./springapp/war/WEB-INF/jsp

    and i have my .jpg in the same folder as my .jsp files (shown above). should i include /war/WEB-INF in the declaration <img src="/war/WEB-INF/file.jpg">?

  6. #6
    Join Date
    Aug 2004
    Location
    The Netherlands
    Posts
    160

    Default

    This make the problem clear, do not put your image file in the web-inf folder, but create an image folder in the root of your web project like this

    projectroot
    projectroot\web-inf
    projectroot\images
    projectroot\style

    etc

    then your image would be like

    <img src="images\test.jpg"/>
    Jettro Coenradie
    http://www.gridshore.nl

  7. #7

    Default confirmed solution

    thanks for the help.

    finally got to test it and i have to put the folder 'images' in my 'war' directory.

    filesystem (partial):
    springapp/src
    springapp/war/WEB-INF
    springapp/war/WEB-INF/jsp
    springapp/war/WEB-INF/classes
    springapp/war/images

    and both <img src="images/file.jpg"> and <img src="images\file.jpg"> work in my .jsp file.

    finished this post with an answer....since ive seen so many posts where someone has the same problem as me then finishes the post with "FOUND OUT MY PROBLEM" with no solution posted.

Posting Permissions

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