This may look like a sally question, but I really don't have an idea about how do they work, anf how do I use them. Can anyone give me an example of a reusable tag, and a tag lib? Are those related to java packages?, or java beans? Thanks.
Chk out these tutorials. for details. Basically Tag Libs are a way to develop your own tags like the ones you use in HTML ex: H1, H2 etc for headings etc. Not direclty related to packages or beans, but they can be developed using bean concepts. regds. - satya
Take a Minute, Donate an Hour, Change a Life
JSP Tags have whatever behavior you program into them. There are tags that allow logging to occur from your JSP page so you can track thing. The Jakarta full Tag Lib has session tags, request and response tags, log tags, db tags etc. ------------------ Hope This Helps Carl Trusiak, SCJP2
Taglibs are a collection of Java Classes that follow the Java Beans model ,and implement a particular function ( like iterating thru a collection or a recordset).These functions are accesible in JSP using custom tags. Custom tags are similar to ordinary tags in HTML like <HTML>/<HTML> , <BODY>/<BODY>. You can specify your own name for these with a set of attributes foe each tag. Each tag would have a TagHandler class ( the Java Class I mentioned above), that would implement a Tag Interface or derivative of it (javax.servlet.jap.tagext.*). The TagHandler would need to have a setter method for each of the attributes. The Tag Handler would implement the exact function of the Tag and a TagLibraryDescriptor (which is a XML file) would create a mapping between the tag handler class and the tag name. It would also contain additional details on the attributes, their types,variable defined by the tag if any ,and auxiallary calsses to validate the tags. eg: <foo:customtag attri1="val1" attr2="val2"> //Body of the tag </foo:customtag>
yep and the best part about defining your own tags is 1. you have no trouble implementing OLAF (one look and feel in your application or across multiple applications) 2. Changes/modifications have to be made in one place and not in individual jsp's 3. You are following sun's new pattern Model-View-Control to the t (or is it z...) and i really want this book :-) -manav
I don't understand why do we need to specify the prefix attribute in the taglib directive though. I think specifying the uri attribute should be enough to let the JSP container to look for the tag because the tag tld already linked the uri "name" to the "tag".
The prefix is especially useful when you are using more than one library of tags in a particular JSP to prevent name conflicts.
Adam Chace<BR>Author of :<A HREF="http://www.amazon.com/exec/obidos/ASIN/193011009X/electricporkchop/102-2552103-3190518" TARGET=_blank rel="nofollow">JSP Tag Libraries</A><BR><A HREF="http://www.chalkcreek.com" TARGET=_blank rel="nofollow">Chalk Creek Software</A>