• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsp include vs. link tag for including CSS

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was wondering as to the pros and cons associated with including an external CSS file for a page.

So far the main thing I come up with is that <link...> is client-side relative whereas the the <jsp:include ...> is server-side relative in terms of the CSS file's location.

Is there anything more substational than this? performance hits associated with the jsp:include?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The link tag will allow the browser to cache the CSS file. I've never seen a CCS page included on the server side and would consider that a poor practice.
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have done a combination of this before, using a <jsp:include> that would include a jsp, that renders the <link> tag for css.

the included file is a jsp, that contains the <link>tag to load either the external style sheet, or an inline style sheet, still within the <link> tag.

when i make a seperate file to put my css <link> tags, and other header type things that are common to all pages in my site, it saves me from having to cut-paste across all top level pages when something changes.
It is sort of like server side templating / organization of your conent. If you are used using the tiles framework, or similar, this jsp:include model fits nicely with the <tiles:insert> tags.

The motivation of using <jsp:include would render the contents of the seperate my_header.jsp is that the jsp becomes its own servlet, so the invocation is more like a function call, as opposed to if you <%@ include %> 'd it, then it would be verbatim inline with the calling servlet, which IMHO makes makes each file slighly unnecessarily larger and may at times (conspiracy theroy) take a little longer for the JSPs to compile (when you have hundreds)
I also prefer the <jsp:include over the <%@ include %> as I have noticed sometimes, on older (websphere) app servers do not always know to recompile a JSP when the <%@ include %>'d file is changed.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd say that the decision to use an include directive vs. an include action should be made depending on whether it makes sense for a separate (sub)request to be made to the resource or not --not to get around a container issue.
 
reply
    Bookmark Topic Watch Topic
  • New Topic