tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Everman <ever...@precedadesign.com>
Subject Re: Question about context paths and IMG URL's
Date Fri, 28 Jun 2002 19:07:24 GMT
Using "/xxx/yyy" in HTML will cause problems if you are not in the default 
context because it will point directly to the host root.  I would almost 
say that an HTML relative reference starting with "/" is *always* wrong 
unless your working within a cooperative environment where you know what is 
at the server's root.

Personally, I always include a dynamic HTML Base tag in all pages that 
points to the current context root.  Thus, all relative URLs (not starting 
with a '/') point to the context base.  This is a bit of a pain when you 
want to point to a resource that is -right next to- the current page, but 
in the long run it makes things easier for included pages since all 
relative references start from the same base.

As an example, if you have a shared page that is @included (not 
jsp:include) in other pages, relative references in the included fragment 
would be relative to whatever page their used in, resulting in lots of 
broken img tags.  By consistently specifying a base, you can prevent this 
from happening.


Cheers,

Eric Everman



At 12:21 PM 6/28/2002, you wrote:
>I seem to have confused myself about the proper way to specify an image
>location in HTML that my servlet spits out.  If I have an "images" directory
>at the "root" of my webapp, is it safe to always do this:
>
>    <img src="/images/foo.gif">
>
>Or, how does the context "path" attribute play into this?  We always set our
>path to "" (our app is the only one running in the container).  But, I'm
>wondering about this if we wish to make it a bit more generic so that we
>could just give a customer a WAR file and let them set it up in their
>container as they wish.
>
>____
>Chris Bailey       mailto:chris@codeintensity.com
>Code Intensity       http://www.codeintensity.com
>
>
>--
>To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message