• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A knowledge to share..

 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
question from Enthuware mock.

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.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for sharing
We also have a related FAQ about the body-content for tags.
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
Kosala W.Abayagunawardene
Ranch Hand
Posts: 47
Firefox Browser Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks cleared my doubts.
 
Hasnain Javed Khan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WoW . Thanks a million for sharing
Kind Regards.
Hasnain
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic