Nov 25th, 2005, 04:42 PM
displaying an image
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,
Nov 26th, 2005, 01:43 AM
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.
Nov 26th, 2005, 02:02 AM
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.
Nov 26th, 2005, 02:06 AM
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:
have a look at your war file and see if your image is in the war file.
Nov 26th, 2005, 02:09 AM
where should the image be?
my filesystem is like this:
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">?
Nov 26th, 2005, 02:29 AM
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
then your image would be like
Nov 26th, 2005, 05:48 PM
thanks for the help.
finally got to test it and i have to put the folder 'images' in my 'war' directory.
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.