Given that a tag testlib:myFirstSimpleTag extends SimpleTagSupport. What should be done so that scriptlet code can be used in the body of this tag?
1. body-content should be set to JSP in the TLD for this tag. 2. scripting-enabled should be set to true in the TLD for this tag.
3. Create a classic tag adapter for this tag that has the body-content of JSP.
4. This cannot be done because it is a Simple tag. 5. None of these.
I just wanted to share with the ranchers , who goona write the SCWCD soon From the above option you might be temped to select option 1 as like i did
but actualy option 4th one is the correct choice.
To use scriptlets in a tag's body, its body-content must be JSP. Now, the body of a SimpleTag is translated into a JSP fragment and since JSP fragments do not support scriptlets, the <body-content> of a SimpleTag cannot be JSP. A TLD is invalid if it specifies JSP as the value for <body-content> for a tag whose handler implements the SimpleTag interface. JSP containers are recommended to but not required to produce an error if JSP is specified in this case.
moreover according to spec JSP 2.0 A translation error must occur if a piece of JSP code that is to be translated
into a JSP Fragment contains scriptlets or scriptlet expressions.