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 body-content default? 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 "body-content default?" Watch "body-content default?" New topic
Author

body-content default?

Ernesto Leyva
Ranch Hand

Joined: Feb 23, 2006
Posts: 62
Hi again

Does somebody know what is the default
if no <body-content> element is defined
in a TLD?

Thanks
Akshay Kiran
Ranch Hand

Joined: Aug 18, 2005
Posts: 220
the default is JSP


"It's not enough that we do our best; sometimes we have to do<br />what's required."<br /> <br />-- Sir Winston Churchill
Ernesto Leyva
Ranch Hand

Joined: Feb 23, 2006
Posts: 62
Yes that's what I thought but in a mock exam
I got is vendor dependant because this option
is invalid for SimpleTags???
Akshay Kiran
Ranch Hand

Joined: Aug 18, 2005
Posts: 220
<!--
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
-->
<!ELEMENT body-content (#PCDATA) >


Look at the DTD yourself...
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I look at it myself And there is no mention of JSP as being the default value. Are you looking at 1.2 ? The exam is about 2.0.

The spec says :

the <body-content> of a SimpleTag cannot be �JSP�. A TLD is invalid if it specifies �JSP� as the value for <body-content> for a tag whose handler implements the SimpleTag interface. JSP containers are recommended to but not required to produce an error if �JSP� is specified in this case.


And in the DTD 2.0:
<body-content>
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.


[My Blog]
All roads lead to JavaRanch
Kiran Bhangale
Greenhorn

Joined: Mar 02, 2006
Posts: 14
<body-content> of Simple Tag cannot be "JSP". Default to "scriptless" for Tag.


Kiran Bhangale.<br /> <br />SCJP1.4 <br />SCWCD1.4
Kiran Bhangale
Greenhorn

Joined: Mar 02, 2006
Posts: 14
<body-content> of Simple Tag cannot be "JSP". Default to "scriptless" for Tag.
Akshay Kiran
Ranch Hand

Joined: Aug 18, 2005
Posts: 220
Oh shuckssssss

where did u get the DTD for 2.0? its not available on the java.sun.com, neither is the DTD for web-app_2_4 miserable people
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

There is no DTD for the Servlet 2.4 and JSP 2.0. Instead the specification provide the XML Schema Document in the specification PDFs.

As per the JSP 2.0, though it is mentioned that the scriptless is reasonable default for the Simple Tag, it made the <body-content> element mandatary. So there is no default for Simple Tag and Custom tag in the JSP 2.0. For the tag files the default value is scriptless.

This problem is discussed earlier posts. One of the latest is here


Hope this help.

Thanks
[ April 27, 2006: Message edited by: Narendra Dhande ]

Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Aleksander Zielinski
Ranch Hand

Joined: Nov 11, 2005
Posts: 127
I'm not sure Narendra, I think that <body-content> element is mandatory only for Simple Tags, not Custom Tags, and if we don't specify <body-content> in the tld for a Custom Tag, the default will be JSP. I tested it on my Tomcat, I omited the <body-content> element and put scriptlet inside the body of the tag, everything worked fine. You have access to Sun Java Application Server, please check it out.
Ernesto Leyva
Ranch Hand

Joined: Feb 23, 2006
Posts: 62
Yes

I ran the same test in Tomcat5.5. I created a simple tag
then I didn't put the <body-content> in the TLD then
I got an error in my web browser saying the value for
body-content JSP was invalid. So seems tomcat is doing
JSP the default but I belive this is tomcat specific only.

For tag-files you use the TAG directive and yes the default for
it should be "scriptless" this is inconsistence with the other
two tags simple and classic
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

When define the tld for custom tag or simple tag, there is no indication that the <tag> entry is for the simple tag or custom tag. I observe the tomcat behavior that it does not validate the web.xml at the time of deplyment, so if there is any error in the Deplyment descriptor it display at the run-time.

I tested it on the Sun application Server. It is not giving any error at the deploy time but giving error at run-time like tomcat. I define a tag without <body-content>. It allow me to deploy the application, but when invoke the JSP file which is using this tag give the following error.




This shows that the default body content is still JSP for all types of tag. But this is compile-time error.


Thanks
Akshay Kiran
Ranch Hand

Joined: Aug 18, 2005
Posts: 220
Thats because both tomcat and ur sun appl server use the 2.3 dtd.
tomcat users- check out the dtd declared in the xml files
and app server users check out the dtd's in the "schema" folder.
you'll only find xsd's for 2.4 but not the dtd

but don't know about the new dtd...if it really doesn't have a default. but as someone said, its there in the spec.
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,
I mentioned in the previous post that there is no DTDs for these versions
because there are some limitations with DTDs to define XML Schemas. Therefore in these versions the XML definations are in the XSDs instead of DTDs.

Both tomcat 5.5.x and the Java application server use the correct xsds. This is the entries in the web.xml.



The default value of the <body-content> as you mentioned is not directly related to the XML Schema documents of Servlet 2.4 and JSP 2.0. It is related to the TLDs DTD or XSDs. I think the web container supporting 2.4 xsd, have a proper xsd for TLD defination using JSP 2.0.

The entries in my TLD file are :



I think it is problem of how the container parse and interpreate the Schema document.

Thanks

[ April 29, 2006: Message edited by: Narendra Dhande ]
[ April 29, 2006: Message edited by: Narendra Dhande ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: body-content default?
 
Similar Threads
Most Most Confusing Question
doubt in mock regarding body-ontext
taglib descriptor doubt
Default Body Content
allowable body-content values