cancel
Showing results for 
Search instead for 
Did you mean: 

how to display images in JSP

Former Member
0 Kudos

Hi all,

I created a Jsp page and I stored my images in the dist-->images folder and by using the following code

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

<img src="<%=image%>">

I try to display the images in that page.

Yes I am successful in displaying one image.

But my problem here is to display more than two images which are present in that page.

Can any body help me regarding this.

Your help will be highly rewarded with points.

Regards,

Ramana.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ramana,

You can give more than one img tag in a JSP page.

Try this..

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

<img src="<%=image%>">

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

<img src="<%=image2%>">

Also, you can set the height, width and border for an image as

<img src="<%=image%>" WIDTH="300" HEIGHT="300" ALIGN="BOTTOM" BORDER="0">

Regards,

Uma

Former Member
0 Kudos

Hi Uma,

I tried by using the procedure you said. but this time empty screen is appearing after deploying .

Are there any things to be done before we add the code or whatever things to be care ful with please reply.

Regards,

Ramana.

Former Member
0 Kudos

Can you try:

<% String resPath= componentRequest.getWebResourcePath()"; %>

<img src="<%=resPath%>/images/image.gif">

<img src="<%=resPath%>/images/image2.gif">

If nothing happend, go to browser and go to "view source". Maby we will see something.

P. S. I don't see why Uma's code do not work

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Ramana,

Set the image border to 1 and check atleast your borders get displayed. If it displays the border, then the problem may be with your image path.

Before deploying for each modification in your JSP, check the preview of the page using "Preview" tab.

Are you getting any exception?

Check your whole JSP page once again (check all the scriplets).

Regards,

Uma

Message was edited by: Uma Maheswari