struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject RE: Image display problem
Date Tue, 28 Aug 2001 00:27:41 GMT


On Sat, 25 Aug 2001, Jay Patel wrote:

> Date: Sat, 25 Aug 2001 08:21:58 -0700
> From: Jay Patel <jpatel@dexteragroup.com>
> Reply-To: struts-user@jakarta.apache.org
> To: "'struts-user@jakarta.apache.org'" <struts-user@jakarta.apache.org>
> Subject: RE: Image display problem
>
> 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
>

Another option is to include the <html:base/> tag in the <head> section of
your page.  This generates an appropriate <base> element that causes all
relative URLs to be resolved against the URL of the page, rather than the
URL of the submit.

Craig


Mime
View raw message