[thelist] Server page includes: javascript and CSS belong in the header!

Will Budreau Will.Budreau at entrust.com
Fri Feb 16 16:05:53 CST 2007


In our codebase, we use JSP includes and Tiles to nest JSP fragments. 
Sometimes a nested content piece requires supporting CSS styles or Javascript methods not already included in the common headers.

I would like to import a stylesheet or script using standard include headers, but those belong in the <head> only. 
How do you address this issue? 

I can think of three solutions 


	1) Specify a way for an included file/tile to add a CSS or Javascript file to the html <head> 
2) Each JSP documents what supporting static files it needs added to the head. May not be correct if there is not a "head" portion specific to the page scope which requires.  A pain to maintain, valid when the developer follows the page instructions..

	3) Don't worry about it. The pages will render fine, even if they will fail validation. Very maintainable, fails validation  that script tags and imports belong in the head

For number 1), I was thinking that if jsp:include included some optional "cssfile" and "jsfile" attributes and could add content to the page header. But that's not the case.  Suggestions?

Will Budreau 
Principal Technologist 
w: 650-622-3028 
im: binain 

Entrust
Securing Digital Identities
& Information 
 <http://www.entrust.com/> www.entrust.com 





More information about the thelist mailing list