cancel
Showing results for 
Search instead for 
Did you mean: 

Problem finding image

Former Member
0 Kudos

Hi

I want to add an image to my portalcomponent that I have developed in Eclipse. I put the image in the images folder of the project. Add the code to the JSP:

-


<hbj:form id="myFormId" >

<% String ImageURL = componentRequest.getPublicResourcePath() + "/images/logo.gif"; %>

<hbj:image id="Logo" alt="Image not found" src=" <%=ImageURL%> " />

<br>

</hbj:form>

-


This according to the example that can be found in the portal 6.

Deploy the component to the portal.

Result: image is not displayed, "image not found text" is displayed. When I check on the properties and the URL address it shows:

E:\usr\sap\DP1\DVEBMGS00\j2ee\cluster\server0\apps\sap.com\irj\servlet_jsp\irj\root\portalapps\myproject/images/logo.gif

I've checked that the image is present on the folder, it's ok.

Any ideas ?

Best regards.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

<b>Fix your code to following. Replace publicResourcePath with getWebResourcePath</b>

Let say images are stored in dist->images folder then your jsp will the have following code.

<% String image = componentRequest.getWebResourcePath() + "/images/image.gif"; %>
<img src="<%=image%>">

Answers (1)

Answers (1)

Former Member
0 Kudos

Instead of creating a local path, I think you need to create an internet resolvable URL to the image you want to show.

You could use the following code to construct the URL:

String application = componentRequest.getComponentContext().getApplicationName();

String ImageURL= = "/irj/portalapps/"application"/images/logo.gif";

Hope this solves the problem.

Johan