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 "http://myhost.cpy.com/myapp/some_file.jsp"
b) this JSP file contains a reference to a stylesheet, which is stored at
(tomcat-dir)/webapps/myapp/css/style1.css.
The reference in the JSP page is
<style src="css/style1.css" ..>
Since this reference is inside the page which was retrieved as
"http://myhost.cpy.com/myapp/some_file.jsp", the browser interprets this reference as
meaning that it should fetch the resource located at
"http://myhost.cpy.com/myapp/css/style1.css"
and it does fetch it, succesfully.
c) in this stylesheet, there is a reference to an image, stored at
(tomcat_dir)/webapps/myapp/images/image1.jpg.
In the stylesheet, the reference to that image has a URL of
"../images/image1.jpg".
The browser, when comes the time to fetch this image, will interpret this as
"http://myhost.cpy.com/myapp/images/image1.jpg"
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: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org