wood burning stoves 2.0*
The moose likes JSP and the fly likes @include vs taglibs containing jsp elements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "@include vs taglibs containing jsp elements" Watch "@include vs taglibs containing jsp elements" New topic
Author

@include vs taglibs containing jsp elements

Jacob Fenwick
Ranch Hand

Joined: Apr 28, 2006
Posts: 55
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

Joined: Jan 10, 2002
Posts: 60774
    
  65

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jacob Fenwick
Ranch Hand

Joined: Apr 28, 2006
Posts: 55
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

Joined: Jan 10, 2002
Posts: 60774
    
  65

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

Joined: Apr 28, 2006
Posts: 55
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: @include vs taglibs containing jsp elements
 
Similar Threads
Upload multiple files in jsp
Dropdown list
why JSTL than scriptlets?
struts 2 converter on Set data type
Dynamic change the iframe height