You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Braini <br...@gmx.net> on 2002/10/08 10:10:06 UTC

JSP-Tags: bodyContent == null in doAfterBody() in TomCat, not in iPlanet

Hi there
I have a small TagLib Library in developed in iPlanet 6 with java 1.2.2.
There it's working well.
Now a wanted to migrate to Tomcat 4.1.12, Apache HTTP Server 2.0.40,
mod_jk2, J2SDK 1.4.1, Win2000 (for testing, Solaris later)
But there, in the doAfterBody() method of the JSP-Tag I can't get the
bodyContent.
Where the bug? In Tomcat or in me?
Thanks for every hint
  Braini

Following my source files :

------------------- [tagTest.jsp] -------------------
<%@ page contentType = "text/html" %>
<%@ taglib uri="/tlds/tagTest.tld" prefix="myTag" %>

<% String strRoot = request.getContextPath(); %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Braini's tag tests</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
  <h2>Braini's tag tests</h2>
  <h2>Register here with your e-mail address</h2>
  <br>
  <myTag:form language="en">
  <form action="/LDAPaccess" method="POST">
    <b>Mail address: </b>
    <input type="text" name="myTagTest_MAIL_req_1_MAIL"
           maxlength="50" size="30" value="yourname@yourcompany.ch">
    <input type="submit" name="Submit">
  </form>
  </myTag:form>
</body>
</html>


------------------- [tagTest.tld] -------------------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
        PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
        "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
  <tlibversion>1.0</tlibversion>
  <jspversion>1.1</jspversion>
  <shortname>tagTest</shortname>
  <info>Some tests in Tomcat 4.1.12</info>

  <tag>
    <name>form</name>
    <tagclass>ch.TagTest</tagclass>
    <bodycontent>JSP</bodycontent>
    <info>A tag to test bodyContent in Tomcat</info>
    <attribute> <name>language</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>
</taglib>


------------------- [ch.TagTest.java] -------------------
package ch;

import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.http.HttpSession;

public class TagTest extends BodyTagSupport {
  private String strLanguage = "en";

  static {
    System.out.println("TagTest: static: Running static part of tag");
  } //end static

  public void setLanguage(String strLanguage) { this.strLanguage =
strLanguage; }
  public String getLanguage() { return strLanguage; }

  public int doStartTag() throws JspException {
    System.out.println("TagTest.doStartTag: Running");
    return EVAL_BODY_INCLUDE;
  } //end doStartTag();

  public int doAfterBody() throws JspTagException {
    System.out.println("TagTest.doAfterBody: Running");
    HttpSession session = pageContext.getSession();
    BodyContent bodyContent = getBodyContent();
    if(bodyContent == null) {
      System.err.println("TagTest.doAfterBody(): Warning: tagTest:form is
empty");
    }
    else {
      System.out.println("TagTest.doAfterBody(): tagTest:form:\n"
               + bodyContent.getString());
    } //end else(bodyContent present)
    return SKIP_BODY;                 //no further body processing should
be performed.
  } //end doAfterBody()

  public int doEndTag() throws JspException {
    System.out.println("TagTest.doEndTag: Running");
    return EVAL_PAGE;
  } //end to EndTag()
} //end class TagTest


------------------- [System.out / System.err] -------------------
TagTest: static: Running static part of tag
TagTest.doStartTag: Running
TagTest.doAfterBody: Running
TagTest.doAfterBody(): Warning: tagTest:form is empty
TagTest.doEndTag: Running


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>