tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: Links in CSS vs JSPs
Date Tue, 20 Sep 2011 13:26:49 GMT
Patrick Flaherty wrote:

> My question was about why JSP links work *without* the app prefix and 
> the CSS links do not. I think Chris' answer of the JSPs are dynamic
> and intern automatically get the app prefix where CSS are not dynamic 
> and therefore the CSS link has to account for the app prefix.
> How it is fixed André was not the issue, but why JSP links and CSS links 
> behave differently.

I understand. But what I am saying is that I see no reason why the CSS links should have 
to account for the app prefix.
It seems to me that if the CSS links (or rather, the links to images /within/ the CSS 
files) are expressed properly, then they should not have to account for the app prefix.
And that if this is true, it saves a lot of aggravation at various levels.

Or else I am missing something.

Example :

a) a JSP file is located at (tomcat_dir)/webbaps/myapp/some_file.jsp
and the browser calls this as ""

b) this JSP file contains a reference to a stylesheet, which is stored at
The reference in the JSP page is
<style src="css/style1.css" ..>
Since this reference is inside the page which was retrieved as 
"", the browser interprets this reference as 
meaning that it should fetch the resource located at
and it does fetch it, succesfully.

c) in this stylesheet, there is a reference to an image, stored at 
In the stylesheet, the reference to that image has a URL of
The browser, when comes the time to fetch this image, will interpret this as
and fetch it succesfully.

Or not ?

By playing with various techniques as explained by Chris previously, you can in the end 
get the same result.
But what I am saying is that, if the usage is similar to what I am using in the above 
example, applying these techniques should not be /necessary/, if the links themselves are

correctly expressed in the JSP and stylesheet documents.

In my experience, such "dynamic techniques" (or hardcoded absolute links) are necessary
sometimes, when some documents are returned (dynamically) by a JSP page or a servlet (in 
other words, code), because then the browser does not know what the real "base href" is, 
and it can thus get confused.  But not in a case like above, where basically we are 
talking about static documents, retrieved directly by the browser.

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

View raw message