• 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 HeadFirst question

 
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
refering to page 493, chapter 9 JSTL, and question no 9

Which <body-content>element cobinations is the TLD are valid for the following JSP snippet?

<my:tag1>
<my:tag2 a="47"/>
<% a=420 %>
<my:tag3>
value=${a}
</my:tag3>
</my:tag1>

(choose all that apply) from the given options:-

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

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

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

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

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

Given answers are: B, C, E

My doubt is if any tag is already declared to be without body in the TLD file , so how can other options work in this case as sciptless OR JSP. <body-content> empty means tage is not allowed to have body of any kind... if a tag cannot allowed to get body then how would we put body which is either JSP or scripless

Please help me
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very good question, I am also looking answer for this question. Can somebody please respond.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Poonam,

I'm not sure I've understood your question. If the case, could you please rephrase that ?
If your question is how is it possible that the tag2 can possibly be defined as empty, scriptless or JSP
in the TLD, the answer is that every tag, regardless of its body-content definition can be used with
no body, so we cannot infer anything specific about the body-content definition for the TLD of this tag
and this is the reason why all options are acceptable.
Different is the case of a custom tag like tag1 which has a body and other
nested tags. In this case we can infer that its body-content definition in the TLD
cannot be either empty or scriptless, but it must be JSP.

Matteo
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry but my doubt is still not cleared some body else please help to make me understand this that
"How tag2 can have any other options as JSP and sciptless if its <body-content> is empty in the TLD file"


Please Help
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help anybody??
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the body-content is declared as 'JSP' or 'scriptless' in TLD, it can still be used in JSP as a tag with no body.
Eg:
<body-content>JSP</body-content>

JSP:
<my:tag2/> is still valid.

Since the body-content is declared as one other than empty, it is not mandatory to declare the tag with a body.

Hope this clears your doubt.

 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By analyzing the tags we can notice the following:

* regarding the tag named "tag1" it contains the following stuff:

1) other tags
2) a JSP scriptlet

which leads that the possible values of its body-contents is only ... JSP


* regarding the tag named "tag2" its empty so its body-content can be ... empty or tagdependent or scriptless or JSP, note that even if you define a tag body-content to be (JSP, scriptless, tagdependent) for example, when using the tag in your real application you can sometimes use it without any body.

* regarding the tag named "tag3" its contents are an EL expression so its body-content possible values are ... scriptless or JSP.



so to summerize the possible values :
tag1 -----> JSP
tag2 -----> anything
tag3 -----> scriptless or JSP

so the possible answer are: (B , C , and C).

hope it helps to clarify the situation ;-)
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks
it clear my doubts abt the possible values of <body-content> tag and how they behave.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic