What are the different ways of sharing data between tags? which is the best and when will each type be appropriate. could anyone please expand on this topic. Appreciate u'r feedback, Thanks.
posted 15 years ago
I have used two ways.
One is declare pageContext level variables, if the data is shared for several tags, then you have to use it, but the shortcome is that you have to import the necessary library in the jsp. And you also need a extrainfo class to declare it and destroy it in one of tag or declare the variable in the jsp. the second one is in nested tags, use: findAncestorWithClass and get the ancestor and get the data out. You will have to declare the tag in the tld file as can contain jsp in it. here is the official jsp tag tutorial: http://java.sun.com/products/jsp/tutorial/TagLibrariesTOC.html