Project and Portfolio Management Practitioners Forum
cancel

How to bind a image file in jsp

Highlighted
Sascha_1
Super Contributor.

How to bind a image file in jsp

Hi,

 

i try to call a image file from a jsp file. Both files (image.png and report.jsp) are located in the same directory. Acutally i'm trying this one:

 

<img src="myImage.png" alt="Text">

 

But this does not work. The image will not be displayed. Any ideas?

 

Regards,

Sascha

3 REPLIES
Etienne_Canaud
Micro Focus Expert

Re: How to bind a image file in jsp

Hi Sascha,

 

I'm surprised this doesn't work. I tried to reproduce it, and had no problem to display the image by creating a new JSP in <SERVER_HOME>/deploy/itg.war/web/knta/test  with your line of HTML, and a png image in the same folder.

 

One very small issue is that you forgot the closing tag at the end (should be <img src="myImage.png" alt="Text"/>), but all the browsers I tested just ignored this minor syntax error and displayed the image correctly (FireFox, IE 7/8/9, Chrome).

 

The only possibility that I see is that your server is not configured to reload JSP automatically after modification, so you'd need to empty the cache and restart PPM for changes to JSP to take effect ; you can verify this easily by looking at the source code of your JSP once it's rendered in your browser, and verify whether your IMG tag is there.

Note that by default, hot reload of JSPs is disabled in PPM for performance reasons.

 

Just to know, what is the folder where your report.jsp and png image are located?

 

Kind Regards,

Etienne.

Sascha_1
Super Contributor.

Re: How to bind a image file in jsp

Hi Etienne,

 

it's really weird because i found the my img tag at the source code (please see attached screenshots).

But however running it on IE or Firefox, the image will never be displayed.

 

Regards,

Sascha

Etienne_Canaud
Micro Focus Expert

Re: How to bind a image file in jsp

Hi Sasha,

 

I don't see any discrepancy between the source code and the screen capture, given that you added manually the "Image" sourrounded by the red rectangle.

 

Also, the source code seems to be an extract of the source code, not the whole JSP source code (you miss all the <HTML> and <HEAD> <BODY> tags, but still the browsers should be able to render it correctly.

 

Here, the only image that should be displayed is excel.gif, located in ../rpt/excel.gif. If it can't be displayed, the alt text "Export to Excel" might be displayed instead, but I don't know whether it's what happens from the screenshot.

There's no mention of the png file that you are trying to include.

 

Could you attach the source JSP, the rendered full page HTML code, as well as how exactly are the different images (gif, png) and the JSP organized in the folder hierarchy?

 

Kind Regards,

Etienne.