> -----Original Message----- > From: Caldarale, Charles R [mailto:chuck.caldar...@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.good...@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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org