Announcement Announcement Module
Collapse
No announcement yet.
displaying an image Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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.

      Comment


      • #4
        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.

        Comment


        • #5
          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">?

          Comment


          • #6
            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"/>

            Comment


            • #7
              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.

              Comment

              Working...
              X