• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Does Simple Tag cna't contain scripting code?

 
avseq anthoy
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HFSJ p567.It says that simple tags cannot have a body that includes a JSP expression tag.
What if I declare <body-content>JSP<bod-content> in TLD?
[ September 17, 2005: Message edited by: avseq anthoy ]
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Avseq,

Is JSP allowed . I thought there are only these three allowed <body-content> entries:

  • scriptless
  • empty
  • tagdependent


  • Regards,
    Darya
     
    Esam Ahmed
    Ranch Hand
    Posts: 101
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi avseq,

    If you refer to page 472 of HFS/J, you will find a total of four types of body-content value...

    It said that <body-content> element can be one of EITHER THREE OR FOUR values depending on the type of the tag!!!

    So my assumption is that simple tage can have only three values excluding the scripting (which is possible only in JSP)

    I havn't found any explicit references in the book ...about this...
    may be i missed something like you did....

    Hope someone can really clarify this Question 17 on on Page 567

    Esam
     
    Darya Akbari
    Ranch Hand
    Posts: 1855
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi,

    there is a very nice thread concerning Question 17 on p. 557/567: Simple Tag & Classic Tag handler mock exam question - what's YOUR answer?

    Now I have tested the example also with <body-content>JSP</body-content>. The result is a big fat runtime exception :



    See above link for the source code. The useTags.jsp code is Question 17 D's code or better:



    Regards,
    Darya
     
    avseq anthoy
    Ranch Hand
    Posts: 106
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thx for your reply.It is helpful for me.
     
    Denis Duan
    Greenhorn
    Posts: 2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    On the document JSP2.0 page 1-155, it states:

    "The body of a Simple Tag, if present, is translated into a JSP Fragment and
    passed to the setJspBody method. The tag can then execute the fragment as many
    times as needed. See Section JSP.7.1.6 for more details on JSP Fragments.
    Because JSP fragments do not support scriptlets, 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."
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic