Main Content

What is a JSP tag library?

Archive - Originally posted on "The Horse's Mouth" - 2009-05-01 20:29:52 - Graham Ellis

Java programming is very different to writing HTML - web page authors expect a tag based language ... so why not provide one that provides some Java functionality? That's what tag libraries do. My slide shows a piece of Java program - defining a variable and calling a constructor; it's a pretty common thing to code and only two elements change - the name of the class and the name of the object created. And - because the java language and also the compiled class far format are published - geeks with enough knowledge could work out the class file data from the source code.

Using a tag library, a different way is chosen to specify the two things that vary - they're specified as attributes to a tag (and the tag type is used to select which standard profile is required). In that way, all the vital information that is needed to define the Java functionality is actually included within the tag, and there's no Java source code left at all!


A JSP is a web page in which Java is embedded within HTML, with the server processing it and sending only pure HTML to the browser. Using tage libraries, some (or all) of that Java can be replaced by tags which are much quicker to interpret, much more familiar-looking to the web developer, and will be set up to offer a restricted range of options only so they'll be more secure and less error prone.