struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jay Patel <jpa...@dexteragroup.com>
Subject RE: Image display problem
Date Sat, 25 Aug 2001 15:21:58 GMT
Sandeep, 

When you specify an image src as "images/foo.gif" that image will be fetched
from where the context of the servlet or jsp. i.e. if the if the jsp is
/app/jsp/bar.jsp, then the image will be looked up as
/app/jsp/images/foo.gif for that jsp. Same image src will render differently
for jsp /baz.jsp; for baz.jsp, the image will show up correctly since baz is
at a root level and so is the images directory.

To fix this, use the struts <html:img> tag. And specify the locations of the
images in application.properties file. Make sure the you have the leading
"/" for each image specified in the properties file:

Here is an example:

Application.properties:

Image.login=/images/login.gif
Image.logout=/images/logout.gif


HTML:IMG tag:

<html:img pageKey="image.login" height="xxx" width="yyy" />


The html image tag will prepend the proper context in front of the images.

Hope this helps.



Jay Patel
972-701-9773
972-849-0373 Mobile
jpatel@dexteragroup.com
 


-----Original Message-----
From: s k m [mailto:strut@rediffmail.com] 
Sent: Saturday, August 25, 2001 9:18 AM
To: struts-user@jakarta.apache.org
Subject: Image display problem


Hi Friends,

We are facing a problem with image display using JSP. When the page is being
displayed for the first time then the images are being displayed correctly.
However when the same page is being displayed again (after a validation
failure) the images are not being displayed. The same is the problem when
other pages are being displayed (e.g. checking logon and moving to the user
page).  Currently our folder structure is

approot
approot/jsp
approot/jsp/images

and the image is specified as <img src=images/abc.gif>. We tried moving the
images folder to the root and specifying the path from the root as in
/images/abc.gif. However the images are still not being displayed.

What we have observed is that when the validation fails then the image is
accessed from the path /approot/images whereas in the normal case the image
is accessed from /jsp/images.

Does anybody know why this happens ? Any help will be appreciated. 

TIA
Sandeep


 



Mime
View raw message