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 21:43:31 GMT
As you know, your browser will add the missing pieces to the relative 
URL.  The leading '/' in HTML instructs the browser ignore the current doc 
base and use the host base.  For instance:

Document www.myhost.com/papers/rocks/stone.html treats these relative urls 
as follows:
bigstone.jpg  -->       www.myhost.com/papers/rocks/bigstone.jpg
/bigstone.jpg -->       www.myhost.com/bigstone.jpg

If your web application was installed in the 'papers' context - your in 
trouble!  Thus, don't use a leading '/' in HTML relative references unless 
you are intentionally accessing shared resources at the host root.  This is 
an HTML issue and has nothing to do with Tomcat or any other web server, 
other then the fact that the servlet spec makes it easy to install 
applications in any context you choose.  As a result, you have to be 
prepared to run your application at a location other then root.

Does that make sense?

Eric Everman

At 04:26 PM 6/28/2002, you wrote:
>But doesn't that just say the "images" directory _relative_ to the current
>page?  And, given that that page is generated by a servlet, I don't think
>that will work right will it?  Or does that actually say relative to the
>context?  I don't see how though, since this is just HTML and thus it means
>it's relative to the page (unless the servlet container/Tomcat does some
>magic to re-interpret the request?).
>
>-----Original Message-----
>From: Lin, Zhongwu [mailto:Zhongwu_Lin@AFCC.com]
>Sent: Friday, June 28, 2002 12:09 PM
>To: 'Tomcat Users List'
>Subject: RE: Question about context paths and IMG URL's
>
>
>It should be
>       <img src="images/foo.gif">
>J
>-----Original Message-----
>From: Chris Bailey [mailto:chris@codeintensity.com]
>Sent: Friday, June 28, 2002 12:22 PM
>To: Tomcat Mailing List
>Subject: Question about context paths and IMG URL's
>
>
>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>
>
>
>
>--
>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