Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@include vs taglibs containing jsp elements

 
Jacob Fenwick
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the benefits and downsides?
It seems at first glance that there is no benefit to using a tablib that strictly contains jsp elements. It takes more lines of code, and more configuration. Am I wrong about this?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the advent of tag files, I have little to no use for includes.

What makes you feel they use so many more lines or so much more configuration?

And tag files are much easier (and less fragile) to parameterize.
[ September 14, 2006: Message edited by: Bear Bibeault ]
 
Jacob Fenwick
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are looking for parameterization then yes, a taglib is probably better. I suppose it's also arguable that there is a more uniform look to the markup if you use tags everywhere instead of @includes.

However, if all you're doing is including some standard tag files on many pages, then it seems that a @include is quicker.

If I want to use a taglib, I have more code because I have to add at least one extra line to my jsp. I have to include the library the tag is from, along with the tag itself. I have more configuration because I have to add the tag to the .tld file.

Maybe it's not that much more, but I'm just trying to figure out if there's any benefit to justify those two extra lines.
[ September 14, 2006: Message edited by: Jacob Fenwick ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jacob Fenwick:
However, if all you're doing is including some standard tag files on many pages, then it seems that a @include is quicker.


For those sorts of things I use preludes.

In fact, for such things a taglib wouldn't work at all.
[ September 14, 2006: Message edited by: Bear Bibeault ]
 
Jacob Fenwick
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think a prelude or a coda is quite what I'm looking. As I understand them, preludes and codas are placed specifically at the beginning or end of a group of jsp files. I just want to arbitrarily add a static fragment of markup into various jsp files, but I don't want to manually paste the markup into each jsp.

I don't see how why you couldn't use a .tag for including a group of static markup. Maybe I didn't use the right terminology and it confused you. I just mean a plain text file with extension .tag that contains jsp tags/regular html tags that is referenced from a .tld file.

However, I still think @include is quicker.

[ September 14, 2006: Message edited by: Jacob Fenwick ]
[ September 14, 2006: Message edited by: Jacob Fenwick ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic