aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Simple Tag Handler : body-content tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Simple Tag Handler : body-content tag" Watch "Simple Tag Handler : body-content tag" New topic
Author

Simple Tag Handler : body-content tag

Charith Indika Fernando
Greenhorn

Joined: Sep 12, 2005
Posts: 13
hi guys....

in the Simple Tag handler what are the valid values in the body-content tag and what is the default value??

cant u put JSP code in the body of a simple tag?

http://www.jdiscuss.com/Enthuse/servlet/ExamServlet?action=GotoQuestion&questionNumber=9
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
No, you cannot have the JSP inside simple tags. Default value for body-content is scriptles in this tag.


Rizwan
SCJA, SCJP, SCWCD, SCBCD, SCDJWS.
Troy Peter
Greenhorn

Joined: Oct 13, 2005
Posts: 14
Hi,

1) Indeed, you can't have scriptlets or scriptlet expressions.

2) The valid values for body-content are empty, tagdependent and scriptless.

3) I don't think there's a default value for simple tags. I believe Rizwan is talking about tag files, where if you don't define the body-content element, then the container assumes scriptless. However, for any other custom tag, you have to have a body-content element defined.

Regards,
Troy.
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
Yes, I mean for tag files default values is scriptless, for othe custome tags, default value is JSP.
But I am not sure about simple tags? since, we define simple tags in tld file and if we dont give the body-tag,( which is optional according to TLD) what value it takes? JSP or scriptless?

So far I am assuming that default value for simple tags(tag files & tags that extend simple tag support) is Scriptless and for the custom tags(which extends Tag interface) default value is JSP.
Please somebody correct me, if I am wrong.
Charith Indika Fernando
Greenhorn

Joined: Sep 12, 2005
Posts: 13
this is exactly my problem....

Tag files the default is scriptless....

Classic Tags the default is JSP

but in simple Tags what is the default??? coz there's the option of not putting that element in the TLD file...
Troy Peter
Greenhorn

Joined: Oct 13, 2005
Posts: 14
Hi all,

A question for Rizwan and Charith: do you think that the element <body-content> for a tag TLD is optional, whether it be a simple tag or classic tag?

I believe this is where you two get confused... My understanding is that this element is not optional. You have to provide it and specify either of the 3 values. This then implies that simple or classic tags don't have a default value for body-content...only a tag file can have a default value for <body-content> (scriptless). Also remember that a tag file doesn't even use a TLD for definition purpose.

Regards,
Troy
Charith Indika Fernando
Greenhorn

Joined: Sep 12, 2005
Posts: 13
hi all,

i think we need some professional help on this matter.. i read somewhere that the default value for body-content in classic tags is JSP... this is the confusing point...

if i can i'll try to find that link....
Troy Peter
Greenhorn

Joined: Oct 13, 2005
Posts: 14
Hi Charith,

The only trusted source is either

1)you doing the implementation and seeing for yourself that it is indeed the default (meaning you don't even have to provide the body-content element in the tld and it works (don't use any IDE))
2) or showing us an extract from the jsp 2.0 specs from Sun

..otherwise, it'll be another guess just like we're doing here.
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
This is copied straight away from JSP Spec
<!--
The body-content element provides provides information on the content of the
body of this tag. This element is primarily intended for use by page composition
tools.
There are currently three values specified:
tagdependent The body of the tag is interpreted by the tag implementation itself,
and is most likely in a different ´┐Żlangage´┐Ż, e.g embedded
SQL statements.
JSP The body of the tag contains nested JSP syntax
empty The body must be empty
This element is optional; the default value is JSP
#PCDATA ::= tagdependent | JSP | empty
-->

From this it is clear that <body-content> is optional and if ommitted it should be JSP.
I guess(again not sure) for Simple Tags, we should give <body-content> which should contain either empty, tagdependent or scriptless. If we omit giving <body-content> then default to JSP for even simple tags and may result in translation error.
I will verify on this more and also you verify from your side with example and dont forget to continue this thread until we findout exact answer for this.
Charith Fernando
Ranch Hand

Joined: Sep 12, 2005
Posts: 67
testing this will be a good idea...


Charith I Fernando<br />SCJP5, SCWCD, SCBCD, BSc(Hons) IS<br />+94 773 263 222 (mobile)
Troy Peter
Greenhorn

Joined: Oct 13, 2005
Posts: 14
Rizwan,

What you just posted applies to JSP v1.1 and 1.2 and the exam is on jsp 2.0.

This appendix includes the XML Schema and DTD files for tag library
descriptors using each version of the JSP specification (from JSP 1.1 to current).


JSP.C.3DTD for TLD, JSP 1.1
The following is a DTD describing a Tag Library Descriptor file in JSP 1.1
format.


Here's jsp 2.0 relevant text on this issue from the spec:

<xsd: element name="body-content"
type="j2ee:body-contentType">
<xsd :annotation>
<xsd : Documentation>
Specifies the format for the body of this tag.
The default in JSP 1.2 was "JSP" but because this
is an invalid setting for simple tag handlers, there
is no longer a default in JSP 2.0. A reasonable
default for simple tag handlers is "scriptless" if
the tag can have a body.
</xsd : Documentation>
</xsd : annotation>


Regards,
Troy

[ October 19, 2005: Message edited by: Troy Peter ]

[ October 19, 2005: Message edited by: Troy Peter ]
[ October 19, 2005: Message edited by: Troy Peter ]
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
Peter, Thanks for correcting me. Does that mean body-content tag is no more optional in JSP 2.0?
Troy Peter
Greenhorn

Joined: Oct 13, 2005
Posts: 14
Rizwan,

That's it, for simple or classic tags, the <body-content> is required in the TLD. However, for the tag files, body-content (as an attribute of the tag directive) is optional and defaults to scriptless.

Troy
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
Thanks Peter for giving final statement.
Charith Indika Fernando
Greenhorn

Joined: Sep 12, 2005
Posts: 13
Thanks peter... to making this a successful thread...
 
jQuery in Action, 2nd edition
 
subject: Simple Tag Handler : body-content tag