tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeffrey Janner <Jeffrey.Jan...@PolyDyne.com>
Subject RE: Question on Contexts and resource pathing
Date Tue, 02 Oct 2012 20:37:17 GMT
> -----Original Message-----
> From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
> Sent: Tuesday, October 02, 2012 3:18 PM
> To: Tomcat Users List
> Subject: RE: Question on Contexts and resource pathing
> 
> > From: Josh Gooding [mailto:josh.gooding@gmail.com]
> > Subject: Question on Contexts and resource pathing
> 
> > when the application is zipped up and deployed out under
> > $CATALINA_HOME/webapps/ROOT
> 
> For clarification, do you mean deployed _as_ ROOT, or _under_ ROOT?
> Webapps cannot be nested, so no webapp should be deployed _under_
> another.
> 
> > I should be able to build the war to any name I want and still have
> > all of the links work, even if they are referenced like:
> 
> > <link rel="stylesheet" type="text/css" href="/default.css" /> NOT ~>
> > <link rel="stylesheet" type="text/css"
> > href="${pageContext.request.getContext}/default.css" /> or
> > ../default.css
> 
> Remember that relative links are based on the web page the links are
> accessed from, not to the base of the webapp.  You need to use a
> leading slash to base them on the webapp.
> 
>  - Chuck
> 

I think Chuck got his absolute vs. relative pathing confused a bit.
A leading slash, "/default.css", is interpreted relative to the hostname portion of the URL.
 That is, it gets expanded by the client as http://hostname.com/default.css.  If you leave
off the leading slash, "default.css" or "styles/default.css" then it's relative to the parent
URL of the page, i.e. http://hostname.com/pageurl/default.css or http://hostname.com/pageurl/styles/default.css.
This is all done at the client end, before your server ever sees the request.  Therefore,
if you want the references relative to whatever you name the war file, and the name is not
ROOT, you are going to have to include the reference to the context name in your href values.
Jeff 
p.s. And, as well all know, absolute pathing starts at the "http://".


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message