This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
1)What is difference between tag implement by classic tag and Simple Tag 2)Can I nested a classic tag action in the simple tag action please explain 3)Can I nested a simple tag action in the classic tag action please explain 4)Can Classic and simple tag both include jsp in the body.
custom tag can be implemented by simple and classic tag handlers. The simple tag has as its name suggests - simplified API. Especially for body-content execution and evaluation(uses JspFragment).
Looking at the tld one cannot distinguish if the tag is simple or classic.
Classic tag can alone(and not simple tag)can have JSP as body-content. Simple tags need to have scriptless body.
Simple and Classic tags can be nested in each other. Only the issue is if you nest classic tag inside simple tag -
<my:simpleTag> <my:classicTag/> <my:simpleTag>
One needs to use the class TagAdapter for getting parent. Since simple tag is of type JspTag and Classic tag is of type Tag. (Remember Tag is subclass of JspTag).From the API:
Because SimpleTag does not extend Tag, and because Tag.setParent() only accepts a Tag instance, a classic tag handler (one that implements Tag) cannot have a SimpleTag as its parent. To remedy this, a TagAdapter is created to wrap the SimpleTag parent, and the adapter is passed to setParent() instead. A classic Tag Handler can call getAdaptee() to retrieve the encapsulated SimpleTag instance.
TagAdapter(SimpleTag adaptee) - constructor JspTag getAdaptee() - returns the JspTag reference to Classic tag. [[ Gets the tag that is being adapted to the Tag interface.]]