Erik:

This did not seem to work for me.  The varuable is not being
substituted.  I am using TOmcat 5.0.25 so it should implement
JSP 2.0.

Here is what I have in my JSP:

    <% 
      String buttonImageUrl =
PathUtil.getImagePath(request,"layout/homeButtonOver.gif");
      pageContext.setAttribute("buttonImageUrl",buttonImageUrl);
      String overImageUrl =
PathUtil.getImagePath(request,"layout/homeButtonOver.gif");
      pageContext.setAttribute("overImageUrl",overImageUrl);
    %>
    <td><html:link action="/home.do" target="_top" 
          onmouseover="setImage('homeButton','${pageContext.overImageUrl}')"

          onmouseout="setImage('homeButton','${buttonImageUrl}')" 
        ><html:img imageName="homeButton" src="${buttonImageUrl}" border="0"
width="140" height="52" /></html:link></td>

When I look at the source of the generate page, I get this:

    <td><a href="/pricetracker/home.do" target="_top"
onmouseover="setImage('homeButton','${pageContext.overImageUrl}')"
onmouseout="setImage('homeButton','${buttonImageUrl}')"><img
src="${buttonImageUrl}" name="homeButton" height="52" width="140"
border="0"></a></td>

It is taking the variables as literals.

Any ideas?

Thanks,
        Neil

--
Neil Aggarwal, JAMM Consulting, (972)612-6056, www.JAMMConsulting.com
FREE! Valuable info on how your business can reduce operating costs by
17% or more in 6 months or less! http://newsletter.JAMMConsulting.com

> -----Original Message-----
> From: Erik Weber [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, February 10, 2005 9:02 AM
> To: Struts Users Mailing List
> Subject: Re: Handle images path in one place
> 
> 
> Using the expression language, you can build paths like this:
> 
> <html:img src="${somePath}/images/foo.jpg"/>
> 
> The "somePath" variable could be an application scope attribute 
> (ServletContext attribute). I have done this before by writing a 
> (Struts) plugin that gets "somePath" from web.xml (init-param) and 
> stores it as a ServletContext attribute. Then it's availabe (as shown 
> above) in all tags in all your JSPs.
> 
> Not sure if there is a better way but that works. You can change your 
> image URL prefix simply by editing web.xml.
>  
> Erik
> 
> 
> Gaet wrote:
> 
> >Hello,
> >
> >I'm writting a web application using J2EE where several 
> pages can contains the same images.
> >I would like to have the path to these images into one place 
> an if possible into the same place for all images.
> >For instance in a file and have a tag to access like this
> ><html:img alias="dog">
> >
> >like this I can move my images from one folder to another, I 
> will have only one file to update....
> >
> >Does somebody use something similar?
> >
> >TIA
> >
> >Gaet
> >  
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to