Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TLD Question

 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If The Tag Element of a tld file does not have a body-content element, does this mean that this tag must be used as an empty tag ???
And if the tag is declared not have a body, can it contain other tags.
 
Rancy Chadha
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Khaled,

This is what I think are correct answers to your questions:
If The Tag Element of a tld file does not have a body-content element, does this mean that this tag must be used as an empty tag ???

<body-content> element of the TLD file is a mandatory element. If you do not specify this element then you will get an exception with a specific message.
And if the tag is declared not have a body, can it contain other tags.

If the tag is declared to have an empty body in that case only one standard action is allowed in the tag for initializing its attribute i.e. you can use <jsp:attribute> standard action inside the body of an empty tag.

Thanks,
-Rancy
 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Today I read a question from enthnuware mock exam and it says that default value for the body-content is JSP, which means that the body-content is not mandatory. Which one to follow??
 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the quesion :

For a tag to accept any valid jsp code as its body, what should be the value of <body-content> for this tag's taglib descriptor?

And here is one of the correct options :

The <body-content> subelement itself may be absent.
A note below the correct option : If it is absent, JSP is assumed which is OK!

I started to get so confused by doing so many mocks
 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no default for body-content in JSP v.2.0. There used to be a default value ("JSP") in version 1.2 of the spec. Maybe you are using an old version of the book.

In JCP v2.0 (the one on the exam) only the tag directive of Tag files has a defualt value which is "scriptless".
 
Francisco Neto
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think for the JSP spec older than 2.0 the default value is "JSP"

Instead, for both tag files and tag lib the default value is "scriptless" because we do not have the JSP value.

I hope that's it!
 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Accordingly to JSP.2.0 spec (page 3-29):


[ May 01, 2007: Message edited by: Sergio Tridente ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic