struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Max Cooper" <>
Subject Re: [Question] Image path - Best way?
Date Sat, 27 Sep 2003 08:55:18 GMT
Struts has a tag that will put the context path on the front of the src URL
for you. Here's an example:

<html:img page="/images/leiste_oben.jpg" width="430" height="80" border="0"

If you want to reserve the option to internationalize what image gets
displayed, Struts has good support for that, too. For instance, if you have
a button image with some text on it, and you want to be able to show
different images for different languages, you can put the image path in the file and use something like this:

<html:img pageKey="button.clickMe.src"/>

You can also use the altKey attribute of the <html:img> tag to
internationalize the ALT, um, thingy.

<html:img pageKey="button.clickMe.src" altKey="button.clickMe.alt"/>

In your base file, you might have something
like this:

button.clickMe.alt=Click Me

You can override these values for other languages in locale-specific
versions of the file.

One thing to be careful of with specifying images this way is that if you
set the size in the <html:img> tag (which is a good idea to speed rendering
performance in the browser), make sure that all the images for a given
button match the size that is specified.

They don't exist now, but it might be useful if heightKey and widthKey
attributes were added to the <html:img> tag to allow those to be looked up
in the properties file as well. That way you could specify different sizes
for the images if they happen to be different for different locales.

For complete documentation, see the online docs for <html:img>, here:


----- Original Message ----- 
From: "Rajesh M Vasudevan" <>
To: "Struts Users Mailing List" <>
Sent: Friday, September 26, 2003 11:32 PM
Subject: Re: [Question] Image path - Best way?

> Hi guys,
> I tried the following, and it seems to work good:
> <img src="<%=request.getContextPath()%>/images/leiste_oben.jpg"
> height="80" border="0" alt="">
> Is this the right way?  Is there a way to specify it as a Resource? Can
> give me a tutorial link of how to do that..
> Thanks
> Rajesh
> > Hi
> >
> > What is the best way to give image paths in JSP pages?  I see that an
> image
> > path given in a certain way works for .jsp files, but the same path
> > for pages loaded through a .do and vice versa.
> >
> > Is there a standard way that struts instructs by which images can be
> defined
> > in a resource configuration file and refer to them in the jsp pages as
> > resource strings, just like application resources?  OR Is there a way to
> > refer to an image which works well for both .do or .jsp.
> >
> > Please advise..
> >
> > Regards,
> > Rajesh
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > For additional commands, e-mail:
> >
> >
> >
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message