Skip to main content

Blarg #14: Why custom tags aren't worth your time

Posted by jfalkner on May 23, 2005 at 2:42 PM PDT

I think I've decided that custom tags aren't worth your time. Certainly 'classic' custom tags, pre JSP 2.0, are ridicuously hard to use regardless of if you'd actually want to use them. I'm not talking about those. I'm talking about custom tags in general. Simple tags, .tag files, and the whole custom tag mechanism.

We have the JSTL, which includes a few helpful tags that take care of iteration, formatting, and i18n. What else do you need a custom tag for? The only things I can think of are managing form state or coding up some snazzy DHTML widgets, but how often do you do code such snazzy widgets and aren't there plenty of existing form state tag libs? Please tell me. What is a good use for a custom tag, and make sure to explain why it wouldn't be easier to do the same thing using servlet filters or JSP EL expressions. Better yet, show the use and point to the code.

I'll propose it now. Stop encouraging people to make their own custom tags. Especially new developers who don't know better.

A slight revision!

After some feedback, I've decided that I need to soften my stance a little. .tag files are great for abstracting repetitive chunks of HTML, e.g. DHTML widgets such as a rollover effect. Since tag files are taglibs, I think they should be saved. As for the other is still in peril.

BTW, does anyone know of a good example I can reference? I'd love to find a nice DHTML library of taglibs that also takes care of any little cross-browser bug.

Related Topics >>