Joined: 10/01/2008 08:20:15
Let's say for example that you want a tag that will print the number of friends of an user. If he has only one friend, the word "friend" will be in the singular form. If he has more than one friend, then the word is "friends". And if he has no friends at all, then you will print a friendly message saying nobody likes him (or just something like "You have no friends!").
Notice that because you extended from PrintTag, you have access to the following protected instance variables:
Now to use your tag, you need a TLD file. This is a Servlet API requirement and there's nothing we can do about this file, so save the XML below in a file inside the /WEB-INF/tld directory, for example taglib.tld:
Now in your JSP page, you can do this: