You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ralph Schaer <sc...@ess.ch> on 2003/08/28 09:23:24 UTC

tomcat 5.0.9 problem with nested tags

Hi

I have a problem with tomcat 5.0.9. I try to embed custom tags inside
custom tags. With tomcat 4.1.24 this works without any problem. But in
tomcat 5 this errors occurs.

D:\tomcat5.0.9\work\Catalina\localhost\test5\org\apache\jsp\index_jsp.java:105: inconvertible types
found   : test5.ShowFieldTag
required: javax.servlet.jsp.tagext.SimpleTag
          if (_jspx_th_app_showField_1 instanceof javax.servlet.jsp.tagext.SimpleTag)
              ^
An error occurred at line: 17 in the jsp file: /index.jsp

Generated servlet error:
D:\tomcat5.0.9\work\Catalina\localhost\test5\org\apache\jsp\index_jsp.java:106: inconvertible types
found   : test5.ShowFieldTag
required: javax.servlet.jsp.tagext.SimpleTag
            _jspx_th_app_showField_2.setParent(new javax.servlet.jsp.tagext.TagAdapter((javax.servlet.jsp.tagext.SimpleTag) _jspx_th_app_showField_1));


                                                                                                                            ^
Regards
Ralph

Fwd: tomcat 5.0.9 problem with nested tags

Posted by Ralph Schaer <sc...@ess.ch>.
I forgot to add the source and jsp file

package test5;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

public final class ShowFieldTag extends TagSupport {

  private String field = null;
  private int start = 0;

  public ShowFieldTag() {
    init();
  }

  public void setField(String name) {
    this.field = name;
  }


  public String getField() {
    return this.field;
  }
  
  
  public int getStart() {
    return start;
  }

  public void setStart(int start) {
    this.start = start;
  }  



  public int doStartTag() throws JspException {

    if (start != 0) {
      pageContext.setAttribute("elementIndex", new Integer(start));
    }

    if (field.startsWith("show")) {
      return EVAL_BODY_INCLUDE;
    } else {
      return SKIP_BODY;
    }
  }


  public int doEndTag() throws JspException {
    return EVAL_PAGE;
  }


  public void release() {
    super.release();
    init();
  }

  private void init() {
    field = null;
    start = 0;
  }




}






<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/app.tld" prefix="app" %>

<html>
<head>
<title></title>
</head>
<body>
<h1>test</h1>

<app:showField field="notshow">
        <h3>hidden</h3>
</app:showField>

<app:showField field="show">
<h3>show</h3>
        <app:showField field="notshow">
                <h3>inside</h3>
        </app:showField>
        <app:showField field="show">
                <h3>show inside</h3>
        </app:showField>        
</app:showField>



</body>
</html>