I have seen the light.

As part of a new project for work I have finally broken down and learned Struts and JSPs. Struts is tremendously useful. I wish it had been around five years ago when I was up to my ears in webbased applications. But JSPs I've never been impressed with. They are good for templating but the combination of java code and html always seemed crufty. I've been minimizing the amount of code I put in them and certainly prefer to use something like XSL to keep the UI and code separate.

Things are going fine and well, except that now I have a new problem. I want to set up a hosting environment for some friends and family. My sister has a weblog which I wrote as a JSP. I've tried to minimize the amount of java code in it, but it's still brittle. She can code the HTML around it but every now and then her editor breaks it. If she codes by hand then she's even more likely to damage something, and either way she certainly can't modify it with new options. She simply doesn't understand Java code, and honestly there's no reason for her to do so.

But now I've discovered custom taglibs. These are brilliant! From my sister's point of view there are now a few magic tags she can use to do something. My scripts are no longer code, just extensions to HTML, as if there was a new version of Netscape with support for a magic tag. (i remember long ago when we were eager to update our browsers and get us crazy-cool new tags instead of being frustrated at the lack proper support for the existing tags. ahh, those were the days. :).

I think this teaches us a good lesson. Presentation of technology is just as important as it's implementation. To a programmer there is no difference between:

<% Blog blog = Blog.getBlog("rachel");
  for(int i=0; i<blog.getNumEntries(); i++) {
  %>
  this is my <%=entry%>
  <%
  }
%>

and

 <blog name="rachel">
    this is my <entry/>
</blog>

But to a novice computer user who just knows HTML there is a world of difference. With a simple tag lib I have hidden all details about iteration, data access and authentication. Now that's some serious power.

This realization has led me on a quest to find more taglibs that fit a hosting mentality. They are hard to find. Most taglibs are still designed for programmers. Helpers for coding frameworks. Very few are end user oriented. And the few that I've found haven't been so great. Even with such a simple user interface it's hard to find tags that are genuinely easy to use. It takes a lot of work to design usable software, even if it's small, and many times it's easy to create the quick solution and move on to something else. Maybe that's why most tags are still for developers.

My challenge this weekend was to find a tree tag. Something that would generate a DHTML tree with as little work as possible. I was surprised to see how many trees would not even let you specify the tree data from within the webpage. One had three separate files. One for the javascript, one for the style configuration, and one for the data configuration. Great for an advanced webdesigner but not so good for the hosted user. Even some of the taglib based tree scripts did not have optimal user interfaces.

Fortunately we live in the great world of opensource where if you don't like something you can make it better instead of complaining. I downloaded one version, rewrote the tag classes, added some jar packaging, stir in one ant build file: and voila you get treetag now available at code.joshy.org.
It needs more cleanup but it functions, and the UI (API) is very simple. Go check it out.

I only have one question now. To make these tags truely hosting-safe (ie, drop in a magic tag and it just simply works) I want a way to make the tags already be preloaded into the default namespace. Then my users won't have to declare the taglib at the top of the page or use namespace prefixes.

I would like to thank Guy Davis for the original tags which I based mine on.

Talk to me about it on Twitter

Posted October 2nd, 2003

Tagged: java philosophy java.net