• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubt in Q17 in HFSJ Chapter 10

 
Ranch Hand
Posts: 229
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a doubt on Q17 in Chapter 10: Custom Tag Development of HFJS. It says that "Both tags are declared to be non-empty and non-tag dependent in the TLD". From what I've read, the bodies can be: "JSP", "scriptless", "empty" or "tagdependent". Does that mean that the bodies of the simpleTag and complexTag tags can only be either "scriptless" or "JSP"? If they are "JSP", then surely, answers B and D would be correct.
 
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Edmund Yong:
I have a doubt on Q17 in Chapter 10: Custom Tag Development of HFJS. It says that "Both tags are declared to be non-empty and non-tag dependent in the TLD". From what I've read, the bodies can be: "JSP", "scriptless", "empty" or "tagdependent". Does that mean that the bodies of the simpleTag and complexTag tags can only be either "scriptless" or "JSP"? If they are "JSP", then surely, answers B and D would be correct.



hi there, in the page 472, first paragraph saying "....the body-content element can be one of either three or four values, depending on the type of tag."

from here, we can know that inside TLD file, we can declare "JSP","scriptless", "empty", and "tagdependent".

example: (page 473)
<taglib...>
....
<uri>random</uri>
<tag>
<name>advice</name>
<tag-class>foo.Looo</tag-clasS>
<body-content>JSP</body-content>
<attribute>
....
...
</atribute>
</tag>

BUT, inside a Tag file, you can have only 3 values, which are "scriptless"(the default when you dont declare), "empty", and "tagdependent". THERE IS NO "JSP" FOR TAG FILE.

example page 498)
<%@ attribute name="fontColor" required=true %>
<%@ tag body-content="tagdependent" %>
...
...

We CANNOT use scrpiting code in the body of a TAG FILE tag !!! see the big words on page 498.

i hope this is clear.
have fun...
 
Edmund Yong
Ranch Hand
Posts: 229
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The tags in Q17 of Chapter 10 are implemented using custom tag handlers, not tag files. So their bodies can be "JSP" or "scriptless" (since they are non-empty and non-tag-dependent). So I don't see why answers B and D are wrong if the tags are "JSP".
 
Nicky Eng
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
because "JSP" does not mean your body can have scripting...??? all i know is that body cannot have scripting in tag. correct me if i'm wrong.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In JSP 2.0 spec page 191, it indicated

The body of a Simple Tag, if present, is tranlated into JSP Fragment and passed to the setJspBody method. The tag can then execute the fragment as many times as needed. ... Because JSP fragment do not support scriptlets, the <body-content> of a SimpleTag cannot be "JSP"...
 
Edmund Yong
Ranch Hand
Posts: 229
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In JSP 2.0 spec page 191, it indicated

The body of a Simple Tag, if present, is tranlated into JSP Fragment and passed to the setJspBody method. The tag can then execute the fragment as many times as needed. ... Because JSP fragment do not support scriptlets, the <body-content> of a SimpleTag cannot be "JSP"...



You mean simple tags can only have body-content of "empty", "scriptless" and "tagdependent"? What about classic tags?
 
Paul W. Chen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you put JSP in body-content in your TLD for simple tag, you will get the error. For class tag, you can specify JSP if you have class tag alone. But for answer D since scripting element is inside simple tag, hence it is not allowed. So the bottom line is you can not have scripting body content in simple tag.
 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To summarise, I say
simple tags and tag files can have only these three values in body-content
empty
scriptless
tagdependent
but classic tags can have all four values in body-content.
empty
scriptless
tagdependent
JSP
 
Edmund Yong
Ranch Hand
Posts: 229
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replies guys.

To summarise, I say
simple tags and tag files can have only these three values in body-content
empty
scriptless
tagdependent
but classic tags can have all four values in body-content.
empty
scriptless
tagdependent
JSP



Exactly which pages of the specification are the above specified?
 
Nicky Eng
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Edmund, Rizwan is just trying to summarize it, his word was not from any specification. He just being nice to summarize it for more easier reading and understanding.

am i correct, Rizwan ?? hoho
 
I claim this furniture in the name of The Ottoman Empire! You can keep this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic