The "Input" Tag Library What is the "Input" tag library? The "input" tag extension library lets you present HTML
elements that are tied to the ServletRequest that caused the current JSP page to run. That is, using this library, you can easily prepopulate form elements with prior values that the user has chosen -- or with default values for the first time a user hits a web page. This is useful when you need to present the same page to the user several times (e.g., for server-side validation). You can also automatically build up <% for (int i = 1; i <= x; i++) { %> <% } %> And it's only that "clean" because I abstracted away two different sel() functions, one that takes ints and one that takes Strings, both of which return the String "selected" if their arguments match. These functions are included at the top of every page that needs them. This sort of application cries out for some sort of macro- or meta-language, and tag libraries for JSP fit in quite nicely. This sort of problem is a clear-cut case where repetitive work can be cut down through the use of something that acts as the moral equivalent of a macro language. I've therefore decided to write and provide contribute to the Jakarta project -- hoping to make web-application developers' lives a little easier -- a custom tag library called "input" that presents HTML form elements that are prepopulated with default input. The developer selects the default input and uses Maps and other objects as necessary to communicate between the page and the tag library in cases where input benefits from (to the point where it's almost accurate to say "requires") something more structured than Strings (which are the default and usual mediator). The tag library is designed with ease-of-use and ease of reading code that uses it in mind. Miscellaneous notes To make the library more useful, I've taken care to make sure that it quotes appropriate HTML entities correctly, itself, in attribute values and textboxes so that users can input characters like & and ", and your application can do the right thing automatically. You don't have to worry about whether the user has entered a " in a web form, which would screw up the HTML you output back to the user unless handled: Instead of the tag above, the library will output This library differs from similar ones in a number of ways. It attempts to be more general than the similar tags that JRun's tag library supports; this one is open-source, first of all, which I don't believe JRun's is, and it isn't tied to HTML 4.0 attributes. Since you pass in an "attributes" map, you can include whatever attribute/value pairs you'd like. Joseph Ottinger's [1]Form Taglib is thorough and reasonably similar to mine in terms of what it can do. I've optimized mine for a special case -- tying data to the ServletRequest object -- and tried to make it particularly easy to use regardless of how your application structures its data. That is, you don't have to use JavaBeans or create any new classes at all to use this library. You might find that Ottinger's fits your needs better or works more generally with your data, and his library provides support for building up an entire , JavaScript validation, and so on -- stuff I've stayed away from for reasons entirely related to personal opinions and nothing more. (I personally use server-side validation more than client-side validation for just about everything.) His library seems great, overall; pick whichever one seems to make your life easier at the time you're deciding. Shawn Bayern shawn.bayern@oooo.com References 1. http://adjacency.org/formtags.jsp