• 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

lt body-content gt element in TLD

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ranchers,

I need clarification with a question on HFS/J mock exam (JSTL - chapter 9)

Mock exam question 5.

Which <body-content> element combination in the TLD are valid for the following JSP snippet? (choose all that apply.)

11. <my:tag1>
12. <my:tag2 a="47" />
13. <% a = 420; %>
14. <my:tag3>
15. value = ${a}
16. </my:tag3>
17. </my:tag1>


A. tag1 body-content is empty
tag2 body-content is JSP
tag3 body-content is scriptless

A. tag1 body-content is JSP
tag2 body-content is empty
tag3 body-content is scriptless

A. tag1 body-content is JSP
tag2 body-content is JSP
tag3 body-content is JSP

A. tag1 body-content is JSP
tag2 body-content is scriptless
tag3 body-content is scriptless



PLease clarify....

thanks..

Esam.

SCJP 1.4
SCWCD in progres...
 
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
tag1 contains tag2 and tag3 and also a scriptlet. So its body-content should be JSP

tag2 has no body. So its body-content can be EMPTY, SCRIPTLESS or JSP

tag3 has a body and has an EL expression. So its body-content can be either SCRIPTLESS or JSP

Following the above logic, the right answers would be the options 2,3 and 4.
 
Esam Ahmed
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Satish,

You said:
"tag1 contains tag2 and tag3 and also a scriptlet. So its body-content should be JSP

tag2 has no body. So its body-content can be EMPTY, SCRIPTLESS or JSP

tag3 has a body and has an EL expression. So its body-content can be either SCRIPTLESS or JSP"

Ok now:

Regarding tag1:

I understand and agree that tag1 has a body-content and should be only "JSP" since as you said its body contains scriptlet - so scriptless is not an option. Also, empty is not also an option since the body contains scriptlet and other tags.

Regarding tag3:

I understand and agree that tag3 body-content can be scriptless since its body does not contain scriplet. Also, its body-content can be JSP since its body contains EL.

Regarding tag2:

This is what I don't understand.......

It is declared as: <my:tag2 a="42" /> <<<...looks like an empty tag
Now, it looks to me that this tag2 has no body...
Thus it seems to me that it can only be declared as having body-content empty.

I can get this: that tag2 has an attribute which is as: a="42"
So you can probably express it like: a="${42}" ....but how is this considered to be in the body???

Could you please explain ... what i am not understanding righ with this tag2?

Thanks....
Esam
 
Satish Chilukuri
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For a tag, if you specify the body-content not to be EMPTY, it is not mandatory that it should have a body. It can be empty.

So you can probably express it like: a="${42}" ....but how is this considered to be in the body???



'a' is an attribute. If you want to use expressions for attribute values, you specify that while defining the attribute in the tld by having <rtexprvalue> element to be true. Using expressions in attributes is not related to the body-content type.
[ September 13, 2005: Message edited by: Satish Chilukuri ]
 
Esam Ahmed
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"For a tag, if you specify the body-content not to be EMPTY, it is not mandatory that it should have a body. It can be empty."

- This implies that even if you declare the tag2 <body-content> to be JSP or scriptless ... which means it could have a body ..still you could declare it as having no body...?

It wasn't so intuitive to me...(perhaps i missed something about it....)
Thanks a bunch for the clarification...

Esam
 
Satish Chilukuri
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

- This implies that even if you declare the tag2 <body-content> to be JSP or scriptless ... which means it could have a body ..still you could declare it as having no body...?



No... it is the other way around. What I meant was that if you have a tag its body-content declared as JSP, it is not necessary that it should have a body.

If tag2 has its body-content declared JSP or SCRIPTLESS, this would be still be legal:
<my:tag2 a="42" />
 
Esam Ahmed
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Satish..

Thanks again..
Yes, i indeed wanted to say what you just said...must misinterpreted..

Thanks much again,
It was bugging me for a while...

Esam
 
reply
    Bookmark Topic Watch Topic
  • New Topic