tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Links in CSS vs JSPs
Date Tue, 20 Sep 2011 15:42:12 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

André,

On 9/19/2011 6:06 PM, André Warnier wrote:
> What I do not understand here (maybe due to my lack of knowledge of
> JSP pages logic) is why one would need to "fix" anything, if the
> links are correctly spelled-out in the first place, taking into
> account how a browser handles absolute/relative links.
> 
> e.g. imagine this structure :
> 
> (catalina_base)/webapps/ myapp/ (contains *.JSP pages) /images/
> (contains images) /css/ (contains stylesheets)
> 
> If the JSP pages contain links to stylesheets located in
> "myapp/css", their reference should say : href(or
> src)="css/name-of-stylesheet.css"

You can't do this unless all your JSPs are at the same directory
level, say, in "myapp".

> If the css files in turn contain links to images, they can be
> expressed as : src="../images/some-image.jpg" And so on.

This doesn't work if there are JSPs included in others from various
levels in the directory tree. It works great when the world is flat...
after that, everything goes to hell.

> If you then move "en block" the whole "myapp" somewhere else, all
> links should keep working just fine.
> 
> Or does something there not work in a webapp/JSP context ?

That will work in a JSP context... it's just that the recommended
technique is to use "relative-absolute" (a term I just made-up: a URI
starting with a '/') URI to reference everything. With dynamic
includes, etc. it's very easy to get relative links all confused and
nothing works.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk54tFMACgkQ9CaO5/Lv0PBTdQCeIpr6LNVplO0Nbw07rRevjqud
J2wAoL/zIoICL7fx0vinP6AksKFCVBYg
=VcjM
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message