tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeffrey Janner <>
Subject RE: Question on Contexts and resource pathing
Date Tue, 02 Oct 2012 20:37:17 GMT
> -----Original Message-----
> From: Caldarale, Charles R []
> Sent: Tuesday, October 02, 2012 3:18 PM
> To: Tomcat Users List
> Subject: RE: Question on Contexts and resource pathing
> > From: Josh Gooding []
> > Subject: Question on Contexts and resource pathing
> > when the application is zipped up and deployed out under
> 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  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. or
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.
p.s. And, as well all know, absolute pathing starts at the "http://".

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message