File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt in HeadFirst question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt in HeadFirst question" Watch "Doubt in HeadFirst question" New topic
Author

Doubt in HeadFirst question

Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
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


Thanks <br />Poonam Agarwal SCWCD 86%
Deepak Keshari
Greenhorn

Joined: Dec 27, 2008
Posts: 5
Very good question, I am also looking answer for this question. Can somebody please respond.
Matteo Palmieri
Greenhorn

Joined: Sep 09, 2008
Posts: 28
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


SCJP1.4: 96% SCWCD5: 91%
Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
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

Joined: May 12, 2008
Posts: 323
Please help anybody??
Anoopriya Muthuswaami
Greenhorn

Joined: Nov 20, 2008
Posts: 25
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.

Omar Al Kababji
Ranch Hand

Joined: Jan 13, 2009
Posts: 357
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 ;-)


Omar Al Kababji - Electrical & Computer Engineer
[SCJP - 90% - Story] [SCWCD - 94% - Story] [SCBCD - 80% - Story] | My Blog
Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
thanks
it clear my doubts abt the possible values of <body-content> tag and how they behave.
 
Don't get me started about those stupid light bulbs.
 
subject: Doubt in HeadFirst question
 
Similar Threads
Doubt on Qno-:5 Pno-:487(HFS&JSP)
using JSTL query
body-content element combinations in the TLD
Doubt on Q 3 HFSJ chapter 10
lt body-content gt element in TLD