You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Deadman, Hal" <ha...@tallan.com> on 2001/02/07 19:47:36 UTC

is the img tag working?

I am using the Struts html:img tag and I just moved my app from the root
context to a different context. All the other Struts links I have seem to
have prepended the context name in the link. The image tag didn't. Am I
doing something wrong?
 
this jsp:
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
 
<html:img src="/image/odtos_logo.gif" alt=""/>
 
 
generated:

<img src="/image/odtos_logo.gif" alt="">
 
 
when the context root in the application.xml of my ear file is: 
<context-root>odtos</context-root>
 
shouldn't it generate:
<img src="/odtos/image/odtos_logo.gif" alt="">
 
 
Thanks, Hal

Re: is the img tag working?

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
"Deadman, Hal" wrote:

>  I am using the Struts html:img tag and I just moved my app from the
> root context to a different context. All the other Struts links I have
> seem to have prepended the context name in the link. The image tag
> didn't. Am I doing something wrong?this jsp:<%@ taglib
> uri="/WEB-INF/struts-html.tld" prefix="html" %> <html:img
> src="/image/odtos_logo.gif" alt=""/>  generated:
> <img src="/image/odtos_logo.gif" alt="">  when the context root in the
> application.xml of my ear file
> is: <context-root>odtos</context-root>shouldn't it generate:<img
> src="/odtos/image/odtos_logo.gif" alt="">Thanks, Hal

The "src" attribute of the <html:img> tag is essentially copied
unchanged (other than URL encoding), which means you would want to use a
relative path to be independent of the context path you are deployed
under.  This is consistent with the way that <html:link> treats the
"href" attribute.

However, the <html:link> tag also offers the "page" attribute, which
lets you specify a context-relative path, and Struts will add the
context path for you.  How about if we add a "page" attribute to
<html:img>, as an alternative to the "src" attribute, so you can have it
either way?

Craig