You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by michael <m....@serfloware.com> on 2000/07/21 18:15:45 UTC

Problem using BodyTag

 hi,
 
 we've made a simple bodytag for an iteration in a jsp and wanted to try it
 out with tomcat - it doesn't work.
 
 nothing inside the bodytag could be returned to the browser. All the
 bodytag-contents seemed to get lost.
 
 however a tag inside our bodytag was processed as we could see from the
 output we've send to System.out. The only way around this problem seems to
 be writing to bodyContent.getEnclosingWriter()...
 
our configuration is:
  - win 2000 server
  - jdk1.3
  - tomcat 3.1 (also tried tomcat 3.2 beta 2)


 bye,
  Michael and Edmund


RE: Problem using BodyTag

Posted by Jeff Ward <jw...@benefitpoint.com>.
put this in your doAfterBody() function and the content will appear.
    BodyContent body = getBodyContent();
    try
    {
      body.writeOut(getPreviousOut());
    }catch(Exception e){
      e.printStackTrace();
      throw new JspTagException("Unexpected error while writing body
content");
    }
    body.clearBody();
    return SKIP_BODY;

  What is happening is the output inside the tags is going to the body
content of the parent tag, the pageContext.getOut() function always points
to the paren't BodyContent. It is the job of the parent tag to decide if the
output should be written or not (hense the body.writeOut).

  Having the body output it's contents like this is the prefered way because
it will work no matter how many tags within tags you have, also text inside
the body of the tag(on the JSP) is output to the body content so this will
display that as well.

  Hope this helps.
  -Jeff
-----Original Message-----
From: michael [mailto:m.steindl@serfloware.com]
Sent: Friday, July 21, 2000 9:16 AM
To: taglibs-user@jakarta.apache.org
Subject: Problem using BodyTag


 hi,

 we've made a simple bodytag for an iteration in a jsp and wanted to try it
 out with tomcat - it doesn't work.

 nothing inside the bodytag could be returned to the browser. All the
 bodytag-contents seemed to get lost.

 however a tag inside our bodytag was processed as we could see from the
 output we've send to System.out. The only way around this problem seems to
 be writing to bodyContent.getEnclosingWriter()...

our configuration is:
  - win 2000 server
  - jdk1.3
  - tomcat 3.1 (also tried tomcat 3.2 beta 2)


 bye,
  Michael and Edmund