• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Custom Tag Question

 
Ashley Bideau
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Select 1 correct option.

a) JSP

b) jsp

c) tagdependent

d) The <body-content> subelement itself may be absent.

I thought it to be a) but mock engine says d). Can some one explain?

Thanks
Ashley

SCJP 5.0
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought JSP was the default (meaning that's what it is if you don't specify the tag at all) value, which would make A and D both correct.
 
Rodrigo Alvarez
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.coderanch.com/t/171574/java-Web-Component-SCWCD/certification/body-content-default-value

I agree with them: HFSJ says that <body-content> is mandatory.

Default value is "JSP" in the spec, but this value is invalid for Simple Tag => mandatory <body-content> makes sense to me.

j2eecertiface might be outdated (before the Simple Tag days)
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HFSJ says that <body-content> is mandatory.

Default value is "JSP" in the spec, but this value is invalid for Simple Tag => mandatory <body-content> makes sense to me.

j2eecertiface might be outdated (before the Simple Tag days)

I think this explains it; basically it doesn't make sense to have a default value for <body-content> anymore, so it is a mandatory tag without a default value. Instead you would have to specify "JSP" explicitly as the value, making (a) the correct answer to your question as of Servlet 2.4. Of course, if you don't know what else to put there, sensible defaults are "JSP" for classic tags and "scriptless" for simple tags, but these aren't enforced.
 
Ashley Bideau
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Charles for clarification.

-Ashley

SCJP 5.0
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From JSP 2.0 xsd:
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic