Semantic Markup

February 2, 2009 on 9:23 pm | In Programming | No Comments

JSP has warts. For example, tags built using Java can contain <&...> in the body, but tags built as .tag files cannot. But JSP is wonderful for building a semantic layer on top of raw HTML. Finally, we can get beyond the assembly code level. It’s really simple, too. All you need is a single Java-based tag which can echo from an arbitrary resource bundle. Pass the resource key (and the bundle name, if you want to be generic) as a parameter to the tag. Presto! As long as the name of the key is semantic, you can write <st:tag type="my-semantic-name">...</st:tag> instead of raw HTML. If you want to be sexier, you can group the tags and leverage the tag name: <st:my-tag-group type="my-semantic-type">...</st:tag>. The practical side of semantic markup now becomes obvious: You can change the raw HTML in one place and your entire application updates to the new markup structure.

Of course, you don’t have to stop there. How about a smart replacement for <head> that automatically includes your CSS and JavaScript? Even better, make it load either the debugging or minified versions based on a cookie (signed, of course) so you can serve minified to everybody else, but turn on debugging for yourself!

No Comments yet »

RSS feed for comments on this post.

Leave a comment

You must be logged in to post a comment.

Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds. Valid XHTML and CSS. ^Top^