tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: Problems upgrading to Tomcat 7
Date Tue, 31 Jul 2012 08:10:21 GMT
Christopher Schultz wrote:
> Hash: SHA1
> Alejandro,
> On 7/30/12 5:48 PM, Alejandro Mehring wrote:
>> I'm migrating to Tomcat 7 a web system that used to run on Tomcat
>> 4...
> Been there (though I went through 5.5 and 6.0 to get there in a
> relatively short amount of time).
>> So far, I've been able to sort out all of the issues I've faced,
>> but I'm stuck at one point. When a page loads in Tomcat 4, it goes
>> and fetches the stylesheet from the server with a link of the form
>> <link type="text/css" href="../lightStyle.css" rel="stylesheet">
> Although this should work, I always recommend using context-relative
> URLs like this:
> <link type="text/css" href="<%=
> response.encodeURL(request.getContextPath() + "/lightStyle.css") %>" />
> This will ensure that your URLs resolve properly no matter how the
> .jsp is being evaluated (for instance, in an include or after a
> forward, where the client's URL may not match what your JSP expects).
>> But on Tomcat 7, the parent directory indirection is removed, and I
>> can't seem to find the way to prevent this from happening!
> That doesn't seem right.
>> What confuses me more, is that when Tomcat generates the *
>> files, both 4 and 7 versions generate a line of code like this
>> one:
>> out.write("<link rel=\"stylesheet\" href=\"../lightStyle.css\" 
>> type=\"text/css\">\r\n\r\n");
>> So i can't figure out why the rendering process is removing the
>> '../' bit of the link!
> I have a hard time believing that Tomcat is modifying anything: in the
> case above, Tomcat does not interpret anything at all. As far as
> Tomcat is concerned, the above is just a string of characters like
> "Hello, World" and has no URL context or anything like that.
> Are you sure this isn't being included by another JSP or forwarded
> from another URL?
>> Has anyone faced this problem before? I haven't found any parent
>> directory restriction configuration or something that would point
>> me in that direction.
> What does the output of the JSP look like? That is, what is the actual
> content of the page as seen by the client?


And, what does that request for the stylesheet actually look like, when it is sent by the

client (the browser) to the server ?
You can find that out by using one of the browser plugins like Fiddler2 (for IE), HttpFox

(for Firefox) or similar.
The point is : this "href" is interpreted *by the client* and converted to a full HTTP 
request URL (with hostname, path and all), before being sent to the server.
The server always receives an absolute URL, starting at the root.

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

View raw message