Hi, I have just been reading on custom tags and was unable to find a suitable example where it could be used. Can you mention use of these tags in some of your live projects ?? Varun Narula
There are only 10 types of people in this world; those who understand binary and those who dont<p>Varun Narula <br />SCJP, SCWCD, IBM-486 (UML)
iteration over uniform and hierarchical collections (such as menus for navigation)
conditional logic
presenting content based upon security roles
locating information from the model (in MVC)
locating information from an EJB layer (in smaller apps)
checking values of cookies
generating HTML controls such as drop downs and lists from collections of JavaBeans
Basically, tags are great for any type of presentation related logic that you would normally code with scriptlets. There are many, many more uses but I hope that's useful for starters... Simon p.s. check out the sample chapters from Professional JSP Tag Libraries for some more examples [ July 18, 2002: Message edited by: Simon Brown ]
For me the "bottom line" with custom tags is that they are another way of getting code out of scriptlets and into proper Java. I have been burned too many times with bugs and even compilation errors in scriptlets which don't show up until long after a web application has been deployed. Now I hate seeing code in JSPs. Custom Tags allow all that yucky scriptlet code to be simply moved to regular Java classes, where it can be compiled and tested before deployment rather than waiting for the live system to fail. Also, because they are well-formed XML, you can use XSLT to style your JSPs. Bonus!
Is there something that can only be done by using Custom tags ? Is the primary objective of custom tags separation of Java code from the HTML ?? Varun Narula
Is the primary objective of custom tags separation of Java code from the HTML ?? Yes, and all the side benefits that gives: compilation and testing of code before deployment, more readable JSP source, easier re-use of tag code etc. etc. I can't emphasize this enough, putting raw Java scriptlet code in JSP pages is bad. You should feel naughty when you do it, and move the code out to something more reliable, readable, reusable and testable as soon as you can.
Originally posted by Varun Narula: Is there something that can only be done by using Custom tags ?
Frank is right, there are so many benefits in using tags over code in the page. As for something that can't be achieved (easily) using scriptlets, check out this thread. Simon
Joel Salatin has signs on his property that say "Trespassers will be Impressed!" Impressive tiny ad:
Gift giving made easy with the permaculture playing cards