C
Chris Riesbeck
When a link to an external stylesheet is redirected
by a servlet, shouldn't relative url's inside it
be resolved against the new location?
I have a servlet that calculates the locations of certain
files in a webapp, e.g.,
<frameset ...>
<frame src="/myservlet?get=foo.html">
myservlet figures out what directory in the webapp
has foo.html and finishes with a
response.redirect(location + file)
Relative URL's in foo.html work as I expect -- they
look for files relative to the redirected location
of foo.html.
But when I use the servlet to locate a stylesheet, e.g.,
<link rel="stylesheet" type="text/css"
href="/myservlet?get=foo.css">
and foo.css has a url() in it, e.g.,
body { background: url(../images/bkgd.gif) }
the image is not found. The rest of the stylesheet
is picked up, but not the image. The image is picked
up if I replace the relative url with a full path,
or use the servlet to calculate the location, but
both approaches are much clumsier than a simple
relative URL.
This happens in IE 6, Mozilla 1.1 and Opera 7, using
Tomcat 4.1.
Is there a bug with Tomcat, my browsers, or,
more likely, my brain?
by a servlet, shouldn't relative url's inside it
be resolved against the new location?
I have a servlet that calculates the locations of certain
files in a webapp, e.g.,
<frameset ...>
<frame src="/myservlet?get=foo.html">
myservlet figures out what directory in the webapp
has foo.html and finishes with a
response.redirect(location + file)
Relative URL's in foo.html work as I expect -- they
look for files relative to the redirected location
of foo.html.
But when I use the servlet to locate a stylesheet, e.g.,
<link rel="stylesheet" type="text/css"
href="/myservlet?get=foo.css">
and foo.css has a url() in it, e.g.,
body { background: url(../images/bkgd.gif) }
the image is not found. The rest of the stylesheet
is picked up, but not the image. The image is picked
up if I replace the relative url with a full path,
or use the servlet to calculate the location, but
both approaches are much clumsier than a simple
relative URL.
This happens in IE 6, Mozilla 1.1 and Opera 7, using
Tomcat 4.1.
Is there a bug with Tomcat, my browsers, or,
more likely, my brain?