Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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

EVAL_BODY_BUFFERED ?

 
Neil Mc
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

On a simulated exam I sat, one of the questions stated that returning EVAL_BODY_BUFFERED from a class which extends TagSupport would cause a runtime exception and NOT a compiler error. It said that the compiler could not check this at compile-time ?

As EVAL_BODY_BUFFERED is defined in BodyTag (which is a peer to TagSupport) I'm wondering why the compiler can't check this at compile time ?

I would have thought that as the compiler can't see this constant, then it could indeed carry out a compile time check.

While, I'm on the subject.... the question contains the following (which it doesn't see as an error).....



I was under the impression that the body of a custom tag CANNOT contain scripting elements ? Is this not the case ?

Any help, much appreciated,

Neil
[ November 01, 2004: Message edited by: Neil Mc ]
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy -- I'll answer *half* your question

We didn't really explain this well in the book--

On page 472, we show the FOUR different values that you can have in a TLD for <body-content>
* empty
* scriptless
* tagdependent
* JSP

But... only THREE of these can be used in SimpleTags or TagFiles--
* empty
* scriptless
* tagdependent

So, you're right about TagFiles and SimpleTags, but Classic tags *can* have scripting elements (or anything else that can go in a JSP) as long as the <body-content> has a value of JSP.

cheers,
Kathy
 
Giju George
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it should generate a compile time error, since EVAL_BODY_BUFFERED is visible ONLY when the class extends BodyTagSupport
 
Neil Mc
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers Kathy, and Giju... I just tried to compile that return value and it looks like you're right (and wizlabs are wrong )

Thanks.
 
pallavi utukuri
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
soo SimpleTags or TagFiles can have
* empty
* scriptless
* tagdependent

while Classic tags can have JSP also...ryt?
defualt for all is scriptless ryt?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic